Skip to content

Block Editor, Editor: Use WPDS tokens on raised surfaces - #87841

Merged
ciampo merged 1 commit into
trunkfrom
update/editor-raised-surface-strokes
Dec 2, 2026
Merged

ciampo merged 1 commit into
trunkfrom
update/editor-raised-surface-strokes

Conversation

@ciampo

@ciampo ciampo commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What?

Follow-up to #87287 (follow-ups 2a and 5). See #75266. Companion to #87840, which does the same for @wordpress/components.

The URLInputButton modal in @wordpress/block-editor and the collaborators popover in @wordpress/editor now use WPDS tokens for their stroke, background and shadow. The block switcher preview keeps its toolbar-style stroke, with a comment that points to the block toolbar work.

Why?

These two raised surfaces hard-code $gray-300 strokes, a $white background and $elevation-* shadows, so they don't follow the theme. On a dark theme they stay white. The design system hasn't decided yet whether raised surfaces should have a stroke (#87287, follow-up 2), but the strokes that exist today should still use tokens.

How?

  • Stroke: $gray-300 becomes --wpds-color-stroke-surface-neutral, and $border-width becomes --wpds-border-width-xs. In the URLInputButton modal, this also covers the divider next to the back button. The collaborators popover keeps its stroke on the top and left edges only.
  • Background: $white becomes --wpds-color-background-surface-neutral-strong, the background that Popover already uses.
  • Shadow: $elevation-x-small and $elevation-small become --wpds-shadow-outer-xs and --wpds-shadow-outer-sm. On the default background the tokens resolve to the same layers, so the shadow looks the same as trunk.
  • Collaborators popover text: the title, count, close button and names use the foreground tokens instead of $gray-700 and $gray-900. Without this, the names would be dark text on a dark background in a dark theme.
  • Block switcher preview: the $gray-900 stroke matches the high-contrast block toolbar, so it stays. A comment links to Applying design system foundations to the Block Toolbar #67426 and Toolbar: Paint the floating toolbar with the Menu surface. #84567, which changes the block toolbar and drops this stroke.

On the default theme, the only visible change is a slightly different gray: #dbdbdb instead of #ddd.

Testing Instructions

  1. Enable Enable real-time collaboration in Gutenberg > Experiments. Open a post in the editor, and open the same post in a second browser as another user.
  2. Click the collaborators avatars in the editor header. The popover should look the same as on trunk.
  3. URLInputButton has no caller in Gutenberg. To check it, render <URLInputButton url="https://wordpress.org" onChange={ () => {} } /> from @wordpress/block-editor in a block or a Storybook story, and click the link button. The modal should look the same as on trunk.
  4. Optionally, render either surface inside a ThemeProvider with a dark background, such as #1e1e1e. The surface should be dark with light text, like the screenshots below.

Testing Instructions for Keyboard

No interaction changes. The collaborators popover and the URLInputButton modal open and close with the keyboard as before.

Screenshots or screencast

Storybook, using temporary local stories that render the two components (the stories are not part of this PR). Before is trunk (1e3f8e76cbb), After is this branch.

Collaborators popover, dark color theme:

Before After
Collaborators popover stays white on the dark theme Collaborators popover follows the dark theme
Light color theme, and the URLInputButton modal

Collaborators popover, light color theme. No visible change.

Before After
Collaborators popover on trunk Collaborators popover on this branch

URLInputButton modal, light color theme. No visible change.

Before After
URLInputButton modal on trunk URLInputButton modal on this branch

URLInputButton modal, dark color theme. The white background and light stroke become the dark surface and its stroke.

Before After
URLInputButton modal with a white background on the dark theme URLInputButton modal with the dark surface on the dark theme

Follow-ups

The collaborator avatar draws a hard-coded $white ring, which shows in the dark screenshot above. Instead of changing that ring to a token, the collaborator UI should move to the @wordpress/ui Avatar, which was built for collaborator avatars. I checked the risks in the post editor on a local site (see the details below). The steps are:

  • 1. Move the canvas overlay CSS to a CSS module. collaborators-overlay injects about 380 lines of CSS written as TypeScript strings (avatar-iframe-styles.ts, overlay-iframe-styles.ts and collaborator-styles.ts). They include copies of base-styles values that must be kept in sync by hand. A .module.scss file in @wordpress/editor reaches the canvas iframe through @wordpress/style-runtime, and it can @use base-styles directly. Done in Editor: De-duplicate the collaborators overlay styles with a CSS module #87862.
    • Add @wordpress/style-runtime as a dependency of @wordpress/editor.
    • CSS modules rename classes. Use :global() or module classes for the classes that other code also uses, such as .block-canvas-cover, .editor-avatar* and the cursor and label classes.
    • The stacking rules that JS generates from MAX_BLOCK_LABEL_AVATARS become an SCSS loop.
    • This step doesn't depend on the Avatar migration.
  • 2. Decide how an inactive collaborator looks. The editor Avatar has dimmed and statusIndicator for disconnected collaborators. The ui Avatar has neither. Either add an inactive state to the ui Avatar, or keep a wrapper in the editor. The ui Avatar passes className and style to its root, so a wrapper can style it. In progress in Editor: Add a collaborator avatar with an inactive state #87889, which keeps dimmed in an editor wrapper. Whether it belongs in the ui Avatar is discussed there. The wrapper drops statusIndicator: no caller has ever passed it.
  • 3. Review the design of the ui Avatar in these places. Decided: the ui Avatar design is the target. Its fill (a darker tint of the collaborator color inside the ring, with initials that contrast with it) and its gap around images replace the editor's solid fill, white initials and white inner ring. What remains is its larger footprint, which steps 4 and 5 handle.
    • Footprint: the ui Avatar reserves a 3px track for the ring, so ui sm takes 27px (a 24px image) against 24px today, and ui md takes 35px against 32px. The editor Avatar draws its 2px white ring with a box-shadow outside its 24px box, so it shows about 28px but reports 24px to layout. The ui Avatar counts the ring in its box, so most of the difference is in layout, not in what people see.
    • The ui Avatar keeps the track, so turning active on or off never shifts layout. Consumers lay out against the footprint. A custom property on the Avatar root wouldn't help them, because a parent can't read a child's custom property.
    • Most layouts don't need the number: translate: -50% centers an element on its own box, the overlap in a group is a design value, and gap spaces a row. Where a layout needs it, the footprint is the size token plus 3px, such as calc(var(--wpds-dimension-size-sm) + 3px). UI: Document the Avatar footprint of each size #87892 documents the footprint of each size.
  • 4. Move the header and the collaborators list to the ui Avatar (collaborators-presence/index.tsx and list.tsx), with color and active, after steps 2 and 3.
    • AvatarGroup stays in the editor. Its overlap and stacking selectors target .editor-avatar children, so they change. Retune its overlap to the 27px box.
    • The list uses CollaboratorAvatar from Editor: Add a collaborator avatar with an inactive state #87889 with dimmed, and keeps the 35px avatar. The row grows by 3px.
    • The list row names the collaborator but doesn't say they disconnected: only the dimmed avatar shows it. Put the disconnected state in the row's text, and hide the avatar with aria-hidden="true", since the row already names the person.
    • The ui Avatar is marked "use with caution", so @wordpress/use-recommended-components fails on the import. Add an inline eslint-disable-next-line with a reason, as core-fields/src/shared/author/avatar.tsx does.
  • 5. Rebuild the canvas badge around the ui Avatar, after steps 1 to 3. The badge stays in the editor: a pill in the collaborator color, with the ui Avatar inside and the name that expands on hover. A cursor label expands on its own hover, and a block label expands when the pointer is over its group. The editor still calculates the name color against the pill color. Replace translate(-11px, -100%) and the stack margins: center a wrapper sized to the avatar on the caret with translate: -50%, instead of a hard-coded offset. Then remove the editor Avatar and its iframe CSS.
What I checked, and how

I added a temporary harness to the canvas overlay and didn't commit it. It rendered the editor Avatar and the ui Avatar side by side, with a .module.scss probe, in the post editor on wp-env (WordPress trunk). I measured the computed styles inside the canvas iframe.

  • ui styles reach the canvas iframe. Iframe wraps its content in StyleProvider, which registers the iframe document with @wordpress/style-runtime. ui CSS modules call registerStyle, so the runtime injects them into that document. The ui Avatar styles, the ui global CSS defenses and the --wpds-* tokens were all in the iframe. wp-theme loads the tokens there. The sizes matched the expected values.
  • A CSS module in @wordpress/editor works too. The probe compiled with base-styles values, and the runtime injected it into the iframe. The editor always renders the canvas in an iframe (shouldIframe in visual-editor), so the overlay never renders without one.
  • Theme CSS and cascade layers. ui styles are in @layer wp-ui, and CSS in a layer loses to theme CSS that isn't in a layer. I tested 9 themes: Twenty Nineteen to Twenty Twenty-Five, the default theme, a dark theme and an empty theme. In all of them, the size, radius, image and initials font of the ui Avatar didn't change. Only two inherited values came from the theme: color on the root, which the initials don't use, and letter-spacing. The current editor avatar takes the theme's font family and size in all of them, including Times in the empty theme.
  • Theme rules that target span and img. I added rules without a layer, such as .editor-styles-wrapper span and .editor-styles-wrapper img, which set font, border, radius and opacity. Both avatars broke. The ui Avatar kept its size, and the editor badge grew from 24px to 46px. The migration doesn't add exposure, but neither implementation fully resists theme CSS on span and img.
  • Lint. Importing Avatar from @wordpress/ui in @wordpress/editor fails @wordpress/use-recommended-components with "not yet recommended". That is why step 4 needs the inline exception.

Use of AI Tools

Written with Claude Code (Claude Opus 5.5), at my direction: Claude made the change, captured the screenshots, and drafted this description.

🤖 Generated with Claude Code

Use the surface stroke, background, and shadow tokens for the URLInputButton
modal and the collaborators popover. The collaborators popover also takes its
text colors from the tokens, so it stays readable in dark themes. Note that
the block switcher preview keeps its toolbar-style stroke, pending the block
toolbar design.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added [Package] Editor /packages/editor [Package] Block editor /packages/block-editor labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: +324 B (0%)

Total Size: 8.73 MB

📦 View Changed
Filename Size Change
build/styles/block-editor/style-rtl.css 20.5 kB +46 B (+0.22%)
build/styles/block-editor/style-rtl.min.css 17.4 kB +36 B (+0.21%)
build/styles/block-editor/style.css 20.6 kB +47 B (+0.23%)
build/styles/block-editor/style.min.css 17.4 kB +33 B (+0.19%)
build/styles/editor/style-rtl.css 32.8 kB +41 B (+0.13%)
build/styles/editor/style-rtl.min.css 28.4 kB +37 B (+0.13%)
build/styles/editor/style.css 32.9 kB +44 B (+0.13%)
build/styles/editor/style.min.css 28.4 kB +40 B (+0.14%)

e27159e Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric c00fcff trunk % Change
timeToFirstByte 56.95 ms +8.52% -3.95% 56.8 ms +9.86% -4.31% 0.26%
largestContentfulPaint 90 ms +8.89% -6.67% 90 ms +6.67% -8.89% 0%
lcpMinusTtfb 31.05 ms +21.58% -7.25% 28.65 ms +22.86% -7.16% 8.38%
wpBeforeTemplate 29.93 ms +11.09% -3.27% 30.34 ms +8.17% -5.17% -1.35%
wpTemplate 22.69 ms +3.17% -3.09% 22.6 ms +5.27% -3.58% 0.4%
wpTotal 52.95 ms +9.27% -3.59% 52.95 ms +9.9% -4.42% 0%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric c00fcff trunk % Change
timeToFirstByte 48.1 ms +9.67% -2.7% 46.95 ms +8.95% -0.64% 2.45%
largestContentfulPaint 84 ms +4.76% -4.76% 82 ms +2.44% -2.44% 2.44%
lcpMinusTtfb 34.8 ms +3.16% -1.87% 33.85 ms +2.81% -1.92% 2.81%
wpBeforeTemplate 27.87 ms +13.17% -2.76% 27.42 ms +7.48% -1.93% 1.64%
wpTemplate 16.91 ms +4.55% -4.97% 16.73 ms +4.72% -2.63% 1.08%
wpTotal 44.71 ms +9.82% -2.77% 43.91 ms +8.38% -1.05% 1.82%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric c00fcff trunk % Change
mediaProcessingJpeg 399.61 ms +0.88% -0.75% 401.04 ms +0.05% -0.16% -0.36%
mediaProcessingAvif 6115.64 ms +0.32% -0.39% 6133.01 ms +0.11% -0.07% -0.28%
mediaProcessingJpegToAvif 4212.5 ms +0.42% -0.33% 4220.59 ms +0.56% -0.2% -0.19%

media-upload

Metric c00fcff trunk % Change
jpegUploadProcessing 1983.54 ms +2.22% -23.41% 1517.22 ms +28.81% -1.6% 30.74%
pngUploadProcessing 279.38 ms +4.3% -2.03% 272.95 ms +3.21% -0.42% 2.36%
largeJpegUploadProcessing 1748.27 ms +12.82% -13.42% 1973.14 ms +0.64% -1.23% -11.4%
multipleImageUploadProcessing 2094.72 ms +1% -5.69% 2107.94 ms +1.49% -5.93% -0.63%

post-editor

Metric c00fcff trunk % Change
serverResponse 274.81 ms +1.32% -3.22% 260.47 ms +2.94% -6.48% 5.51%
firstPaint 301.18 ms +4.59% -7.54% 248.3 ms +2.41% -1.24% 21.3%
domContentLoaded 564.1 ms +6.41% -4.31% 524.56 ms +3.7% -1.13% 7.54%
loaded 565.39 ms +6.4% -4.3% 525.83 ms +3.7% -1.13% 7.52%
firstContentfulPaint 328.4 ms +8.87% -5.91% 295.33 ms +2.66% -1.47% 11.2%
firstBlock 1503.88 ms +2.32% -2.68% 1429.31 ms +0.83% -1.79% 5.22%
type 14 ms +12.43% -7.5% 13.44 ms +6.77% -3.57% 4.17%
typeWithoutInspector 14.18 ms +8.82% -5.01% 14.29 ms +3.78% -15.54% -0.77%
typeWithTopToolbar 18.15 ms +4.9% -7.71% 16.87 ms +2.67% -12.51% 7.59%
typeContainer 6.33 ms +5.37% -11.22% 6.59 ms +1.82% -15.33% -3.95%
focus 74.56 ms +3.11% -1.81% 71.03 ms +3.27% -3.48% 4.97%
firstFocus 173.68 ms +0% -0% 189.79 ms +0% -0% -8.49%
selectAll 239.28 ms +4.25% -0.91% 222.77 ms +9.15% -0.51% 7.41%
undo 19.39 ms +8.61% -4.64% 20.95 ms +6.25% -2.86% -7.45%
listViewOpen 26.49 ms +8.42% -7.81% 24.97 ms +0.8% -5.09% 6.09%
inserterOpen 25.91 ms +2.59% -3.24% 26.75 ms +3.78% -14.47% -3.14%
inserterHover 8.79 ms +4.66% -4.78% 8.19 ms +7.81% -4.64% 7.33%
inserterSearch 6.47 ms +5.41% -7.57% 6.74 ms +2.82% -6.08% -4.01%
loadPatterns 426.55 ms +4.09% -6.2% 417.95 ms +4.39% -2.37% 2.06%
wpTotal 267.08 ms +1.61% -2.95% 253.85 ms +2.97% -6.77% 5.21%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric c00fcff trunk % Change
serverResponse 474.14 ms +0.92% -6.99% 460.42 ms +2.79% -6.41% 2.98%
firstPaint 450.31 ms +3.64% -15.42% 458.19 ms +2.85% -21.72% -1.72%
domContentLoaded 841.14 ms +1.23% -1.41% 839.32 ms +2.89% -1.44% 0.22%
loaded 842.64 ms +1.26% -1.38% 840.96 ms +2.91% -1.41% 0.2%
firstContentfulPaint 467.7 ms +1.16% -1.29% 470.76 ms +1.66% -2.59% -0.65%
firstBlock 2620.83 ms +0.29% -0.85% 2590.38 ms +0.46% -0.42% 1.18%
type 16.6 ms +18.43% -3.19% 16.8 ms +11.37% -8.21% -1.19%
navigate 115.54 ms +3.89% -3.81% 109.57 ms +2.34% -4.02% 5.45%
loadPatterns 1568.64 ms +5.73% -6.47% 1622.97 ms +3.28% -3.52% -3.35%
loadPages 973.56 ms +1.74% -1.5% 952.6 ms +2.29% -1.78% 2.2%
wpTotal 464.76 ms +0.95% -7.13% 450.95 ms +2.84% -6.55% 3.06%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

e27159e Run

@ciampo ciampo self-assigned this Dec 2, 2026
@ciampo ciampo added the [Type] Enhancement A suggestion for improvement. label Dec 2, 2026
@ciampo
ciampo marked this pull request as ready for review December 2, 2026 15:30
@ciampo
ciampo requested a review from ellatrix as a code owner December 2, 2026 15:30
@ciampo
ciampo requested review from a team and Mamaduka December 2, 2026 15:30
@github-actions
github-actions Bot requested a review from aduth December 2, 2026 15:30

@Mamaduka Mamaduka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks, @ciampo!

@ciampo
ciampo merged commit 59501fd into trunk Dec 2, 2026
116 of 117 checks passed
@ciampo
ciampo deleted the update/editor-raised-surface-strokes branch December 2, 2026 22:06
@github-actions github-actions Bot added this to the Gutenberg 24.7 milestone Dec 2, 2026
@ciampo

ciampo commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Thank you, @Mamaduka !

Next up, I'll look into some follow-up work that involves cleaning up Avatar-related custom styles and re-use the new ui/Avatar component, I'll tag you in those PRs for some review help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants