Skip to content

Snackbar: Use WPDS shadow tokens, improve theme inheritance - #87818

Merged
ciampo merged 12 commits into
trunkfrom
update/snackbar-adaptive-shadow
Dec 2, 2026
Merged

ciampo merged 12 commits into
trunkfrom
update/snackbar-adaptive-shadow

Conversation

@ciampo

@ciampo ciampo commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What?

Follow-up to #87287 (follow-up 4). Part of #75266. Stacked follow-up: #87839.

Snackbar now uses --wpds-shadow-outer-sm instead of $elevation-small. In edit-site and boot, snackbars render under the light content ThemeProvider, except over a full-screen mobile area with the admin background in edit-site, where they keep the admin color scheme. The snackbar action and the upload spinner now stay white under a light provider, which also fixes them in the post editor.

Important

Known limitation: the snackbar focus ring can have low contrast on desktop when the snackbar floats over the admin background.

Snackbars are fixed to the bottom center of the viewport, so what sits behind them depends on the screen width, the route and the size of the preview, not on where they render. This PR seeds them for the area they usually cover: the light content. On desktop they can still cover the admin background, for example a long message on a narrow screen, a narrowed preview, or a route with no content area such as Navigation with a classic theme. There, the focus ring is tuned for light content.

With the Blue admin scheme, the ring over the sidebar drops from 5.37:1 (trunk) to 1.59:1, below the 3:1 that WCAG 1.4.11 asks for. With the Modern scheme it stays at 3.54:1. Trunk had the opposite problem in the most common layout: a light ring over light content (1.52:1 with Blue, 2.09:1 with Modern), which this PR fixes. See the "Known limitation" screenshots below and follow-up 1.

Why?

#87287 kept Snackbar on $elevation-small because in the site editor, snackbars render inside the dark admin color scheme provider but float over light content. With the token, they would get the shadow for a dark background, which is 5× stronger (see the "Token only" screenshots below).

How?

  • edit-site (layout/index.jsx) and boot (root/index.tsx, root/single-page.tsx) wrap SnackbarNotices in a ThemeProvider with the content colors. This is the pattern from the theme README's Shadows section. The provider's wrapper uses display: contents, so the snackbar position doesn't change. UploadProgressSnackbar renders nothing, so it stays where it is.
  • In edit-site on mobile, one area fills the screen. When that area has the admin background, the snackbar provider gets no seed and inherits the admin color scheme, so the focus ring keeps trunk's color. This covers the sidebar on routes without mobileContent, such as Navigation, and edit mode on routes without a preview, such as Patterns.
  • In boot, both root layouts share a CONTENT_COLOR constant for the content surfaces and the snackbars. Nested providers inherit the admin scheme's primary color. Admin UI: Share the content background seed for ThemeProvider #87839 moves this value to @wordpress/admin-ui.
  • Snackbar's box-shadow uses var(--wpds-shadow-outer-sm).
  • Two parts of the snackbar read their color from the surrounding theme, which is now light behind the dark snackbar. The pressed action (Button's :active color) now stays white, and the upload progress spinner inherits the snackbar's white text color. The post editor already rendered snackbars under a light provider, so both were already broken there.
  • Code comments in edit-site and boot state the known limitation.

Visible changes:

  • Over light content, the shadow is the same as trunk. The focus ring on a focused snackbar changes from the light blue for dark backgrounds (#8eb0ff with Modern) to the admin color scheme's focus color for light backgrounds (#3858e9 with Modern). The post editor already used #3858e9. Against the #fcfcfc content, contrast goes from 2.09:1 to 5.47:1 with Modern.
  • Over the full-screen mobile sidebar, the focus ring matches trunk, and the shadow is stronger, because the token adapts to the dark sidebar.
  • In the post editor, a snackbar action pressed with the keyboard no longer turns dark (#1e1e1e on the dark snackbar), and the upload spinner is white instead of gray (#6e6e6e). The site editors already showed light colors here on trunk, and they still do.

Testing Instructions

  1. Open Appearance > Editor > Pages.
  2. Show a snackbar. For example, move a page to the trash, or run this in the browser console:
    wp.data.dispatch( 'core/notices' ).createSuccessNotice( 'Changes saved.', { type: 'snackbar' } )
  3. The snackbar shadow should match trunk.
  4. Show a snackbar again and focus it, for example with document.querySelector( '.components-snackbar' ).focus() in the console. The focus ring should use the admin color scheme's focus color.
  5. Narrow the window below 782px and open Navigation. The sidebar fills the screen. Repeat steps 2 and 4. The focus ring should match trunk, and the shadow should be stronger than trunk's.
  6. Enable the Extensible site editor experiment in Gutenberg > Experiments, and repeat steps 1 to 4 in the new site editor.
  7. Repeat steps 2 to 4 on Appearance > Fonts (the boot single-page layout) and in the post editor. The post editor should look the same as trunk.
  8. In the post editor and the site editor, show a snackbar with an action: wp.data.dispatch( 'core/notices' ).createSuccessNotice( 'Page duplicated.', { type: 'snackbar', explicitDismiss: true, actions: [ { label: 'Edit', onClick() {} } ] } ). Focus Edit (for example with document.querySelector( '.components-snackbar__action' ).focus()), then hold Space. The label should stay white. Upload an image to check that the upload spinner is white.
  9. To see the known limitation, switch to the Blue admin color scheme in your profile, set the window to about 800px wide, and show a long snackbar over Pages, for example: wp.data.dispatch( 'core/notices' ).createSuccessNotice( 'Navigation menu "Header navigation" moved to the trash.', { type: 'snackbar' } ). Focus it. The part of the ring over the sidebar is hard to see.

Testing Instructions for Keyboard

No interaction changes. Snackbars still take focus and dismiss with the keyboard as before. Only the color of the focus ring changes, as described above.

Screenshots

Site editor, Pages, 1280×720 at 2×, Modern admin color scheme. Before is 1c0803be314 (trunk), After is this branch.

Before After
Site editor snackbar on trunk, $elevation-small shadow Site editor snackbar on this branch, same shadow from the token
Focused site editor snackbar on trunk, light blue focus ring Focused site editor snackbar on this branch, admin color scheme focus ring

Known limitation

Site editor and extensible site editor, Pages, 800×720 at 2×, Blue admin color scheme, a long focused snackbar. On trunk, the ring is hard to see over the content. On this branch, it is hard to see over the sidebar.

Before After
Site editor on trunk: light ring, hard to see over the white content Site editor on this branch: dark ring, hard to see over the blue sidebar
Extensible site editor on trunk: light ring, hard to see over the white content Extensible site editor on this branch: dark ring, hard to see over the blue sidebar
Mobile: Navigation screen with the full-screen sidebar

390×844 at 2×, Blue admin color scheme, focused snackbar. The focus ring matches trunk. The shadow is stronger, because the token adapts to the sidebar.

Before After
Mobile Navigation screen on trunk, focused snackbar Mobile Navigation screen on this branch, same focus ring and a stronger shadow
Pressed action and upload spinner

1280×720 at 2×, Modern admin color scheme. The Edit action is held down with Space, and the second snackbar shows the upload spinner. On trunk, the post editor already had a light provider behind the snackbar: the pressed label turns dark and the spinner is gray. The site editor had the dark provider, so it was fine on trunk and stays the same.

Before After
Post editor on trunk: pressed Edit action dark and hard to read, gray spinner Post editor on this branch: pressed Edit action and spinner white
Site editor on trunk: pressed Edit action and spinner light Site editor on this branch: pressed Edit action and spinner white
Why the provider move is needed: token only, without the provider move

This shows Snackbar on --wpds-shadow-outer-sm with trunk's edit-site layout, so the snackbar still renders inside the dark admin color scheme provider. The shadow is 5× stronger, and the focus ring keeps the light blue for dark backgrounds. This state is not part of the PR.

Token only This PR
Token only, site editor snackbar with a 5x shadow This PR, site editor snackbar with the trunk shadow
Token only, focused site editor snackbar This PR, focused site editor snackbar
Extensible site editor (boot)
Before After
Extensible site editor snackbar on trunk Extensible site editor snackbar on this branch
Focused extensible site editor snackbar on trunk Focused extensible site editor snackbar on this branch
Fonts page (boot single-page layout)
Before After
Fonts page snackbar on trunk Fonts page snackbar on this branch
Focused Fonts page snackbar on trunk Focused Fonts page snackbar on this branch
Post editor (no change at rest)

The post editor renders snackbars under its root provider, which uses the default background. The token resolves to the same layers as $elevation-small.

Before After
Post editor snackbar on trunk Post editor snackbar on this branch
Focused post editor snackbar on trunk Focused post editor snackbar on this branch
Full screen: site editor and extensible site editor
Before After
Site editor Pages screen with a snackbar on trunk Site editor Pages screen with a snackbar on this branch
Extensible site editor Pages screen with a snackbar on trunk Extensible site editor Pages screen with a snackbar on this branch

Follow-ups

Use of AI Tools

Written with Claude Code (Claude Opus 5.5): Claude made the code change, captured the screenshots with Playwright against a local wp-env site, and wrote this description. A separate agent (Astra 6.2) reviewed the change in four rounds.

🤖 Generated with Claude Code

@github-actions github-actions Bot added [Package] Components /packages/components [Package] Edit Site /packages/edit-site [Package] Boot /packages/boot 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: aduth <aduth@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: -47 B (0%)

Total Size: 8.73 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 54.8 kB +21 B (+0.04%)
build/scripts/edit-site/index.min.js 376 kB +28 B (+0.01%)
build/styles/components/style-rtl.css 18.7 kB -36 B (-0.19%)
build/styles/components/style-rtl.min.css 15.8 kB -19 B (-0.12%)
build/styles/components/style.css 18.7 kB -37 B (-0.2%)
build/styles/components/style.min.css 15.8 kB -18 B (-0.11%)
build/styles/editor/style-rtl.css 32.9 kB +4 B (+0.01%)
build/styles/editor/style-rtl.min.css 28.5 kB +3 B (+0.01%)
build/styles/editor/style.css 32.9 kB +4 B (+0.01%)
build/styles/editor/style.min.css 28.5 kB +3 B (+0.01%)

bff2212 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric a466b30 trunk % Change
timeToFirstByte 60.1 ms +7.74% -5.32% 58.7 ms +3.58% -4.09% 2.39%
largestContentfulPaint 96 ms +4.17% -8.33% 92 ms +6.52% -6.52% 4.35%
lcpMinusTtfb 31.7 ms +22.08% -8.04% 33.25 ms +12.18% -11.58% -4.66%
wpBeforeTemplate 32.03 ms +14.61% -4.75% 30.59 ms +5.36% -1.99% 4.71%
wpTemplate 23.37 ms +7.66% -5.43% 23.12 ms +5.28% -2.29% 1.08%
wpTotal 56.31 ms +7.85% -5.77% 54.57 ms +4.38% -3.74% 3.19%
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 a466b30 trunk % Change
timeToFirstByte 52.4 ms +4.1% -5.34% 48.3 ms +5.9% -1.45% 8.49%
largestContentfulPaint 88 ms +4.55% -4.55% 84 ms +2.38% -0% 4.76%
lcpMinusTtfb 35.65 ms +5.47% -1.96% 35.55 ms +1.55% -3.09% 0.28%
wpBeforeTemplate 30.05 ms +6.76% -4.43% 27.92 ms +1.04% -2.01% 7.63%
wpTemplate 17.39 ms +8.28% -2.19% 17.02 ms +4.64% -2.94% 2.17%
wpTotal 48.86 ms +3.32% -5.49% 44.96 ms +5.85% -1.11% 8.67%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric a466b30 trunk % Change
mediaProcessingJpeg 400.36 ms +0.51% -0.42% 402.18 ms +0.3% -0.99% -0.45%
mediaProcessingAvif 6068.24 ms +0.73% -0.37% 6123.83 ms +0.38% -0.17% -0.91%
mediaProcessingJpegToAvif 4207.74 ms +0.48% -0.8% 4228.53 ms +0.23% -0.38% -0.49%

media-upload

Metric a466b30 trunk % Change
jpegUploadProcessing 1979.55 ms +2.56% -20.22% 1744.7 ms +14.35% -13.28% 13.46%
pngUploadProcessing 284.75 ms +3.27% -2.32% 282.09 ms +3.23% -4.07% 0.94%
largeJpegUploadProcessing 1986.72 ms +0.63% -24.55% 1735.76 ms +13.96% -12.56% 14.46%
multipleImageUploadProcessing 2111.31 ms +1.36% -1.98% 2091.4 ms +1.29% -0.37% 0.95%

post-editor

Metric a466b30 trunk % Change
serverResponse 334.16 ms +2.28% -6.34% 309.38 ms +7.61% -6.34% 8.01%
firstPaint 366.96 ms +1.9% -13.03% 343.9 ms +3.36% -7.17% 6.71%
domContentLoaded 661.04 ms +2.64% -0.55% 645.97 ms +1.54% -1.54% 2.33%
loaded 662.36 ms +2.63% -0.55% 647.29 ms +1.58% -1.51% 2.33%
firstContentfulPaint 370.56 ms +6.62% -1.16% 361.26 ms +5.02% -2.69% 2.57%
firstBlock 1816.89 ms +5.55% -2.14% 1769.83 ms +0.74% -1.26% 2.66%
type 14.88 ms +13.44% -6.65% 15.58 ms +11.49% -2.89% -4.49%
typeWithoutInspector 15.11 ms +8.07% -9.33% 15.34 ms +2.87% -10.43% -1.5%
typeWithTopToolbar 18.94 ms +5.07% -7.55% 19.9 ms +4.87% -11.56% -4.82%
typeContainer 6.93 ms +9.38% -8.37% 6.93 ms +6.64% -12.7% 0%
focus 90.72 ms +4.37% -7.77% 88.19 ms +5.56% -2.32% 2.87%
firstFocus 225.1 ms +0% -0% 223.02 ms +0% -0% 0.93%
selectAll 303.97 ms +0.58% -0.08% 328.58 ms +3.51% -4.5% -7.49%
undo 23.58 ms +10.05% -3.05% 25.08 ms +4.55% -5.7% -5.98%
listViewOpen 33.84 ms +7.45% -10.46% 31 ms +7.84% -2.87% 9.16%
inserterOpen 32.15 ms +5.35% -5.97% 33.91 ms +6.28% -2.42% -5.19%
inserterHover 9.7 ms +10.52% -11.44% 9.65 ms +4.56% -6.42% 0.52%
inserterSearch 6.96 ms +2.87% -6.47% 7.34 ms +8.72% -5.04% -5.18%
loadPatterns 519.22 ms +2.59% -3.86% 517.89 ms +6.18% -4.11% 0.26%
wpTotal 325.51 ms +1.98% -7.02% 300.78 ms +7.82% -6.84% 8.22%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric a466b30 trunk % Change
serverResponse 298.81 ms +5.93% -6.07% 315.04 ms +1.03% -5.15% -5.15%
firstPaint 341.1 ms +9.53% -10.98% 352.74 ms +6.15% -15.69% -3.3%
domContentLoaded 654.61 ms +1.3% -0.67% 657.07 ms +0.85% -1.1% -0.37%
loaded 655.75 ms +1.31% -0.65% 658.35 ms +0.85% -1.1% -0.39%
firstContentfulPaint 374.15 ms +1.36% -1.31% 371.71 ms +4.07% -1.89% 0.66%
firstBlock 2033.95 ms +0.16% -1.23% 2022.14 ms +0.95% -1.07% 0.58%
type 14.13 ms +13.59% -10.12% 14.91 ms +5.1% -5.97% -5.23%
navigate 99.83 ms +6.45% -10.47% 101.19 ms +4.65% -2.62% -1.34%
loadPatterns 1233.91 ms +10.51% -8.12% 1233.33 ms +2.85% -18.85% 0.05%
loadPages 1009.35 ms +0.55% -1.82% 1010.36 ms +2.47% -1.51% -0.1%
wpTotal 290.4 ms +6.12% -6.21% 306.6 ms +1.12% -5.25% -5.28%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

bff2212 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Actions are reachable via RIGHT/LEFT arrow keys in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByRole('row', { name: 'Page One Edit Actions' }).getByRole('button', { name: 'Edit' })
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByRole('row', { name: 'Page One Edit Actions' }).getByRole('button', { name: 'Edit' }) with timeout 5000ms
  - waiting for getByRole('row', { name: 'Page One Edit Actions' }).getByRole('button', { name: 'Edit' })
    14 × locator resolved to <button type="button" tabindex="-1" class="components-button is-small" id="view-list-0-199-primary-action-edit-post">Edit</button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:172:5
should undo without broken temporary state in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:image -->
- <figure class="wp-block-image"><img alt=""/></figure>
+ <!-- wp:image {"id":20,"sizeSlug":"full","linkDestination":"none"} -->
+ <figure class="wp-block-image size-full"><img src="http://localhost:8891/wp-content/uploads/2026/12/4fde10a2-f75a-434d-bebb-f094424484df.png" alt="" class="wp-image-20"/></figure>
  <!-- /wp:image -->
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/image.spec.js:432:49

bff2212 Run

@ciampo ciampo self-assigned this Dec 2, 2026
@github-actions github-actions Bot added the [Package] Editor /packages/editor label Dec 2, 2026
@ciampo
ciampo marked this pull request as ready for review December 2, 2026 15:35
@ciampo
ciampo requested a review from a team as a code owner December 2, 2026 15:35
@ciampo ciampo added [Type] Enhancement A suggestion for improvement. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). labels Dec 2, 2026
@ciampo
ciampo requested review from a team and ramonjd December 2, 2026 15:36
@github-actions
github-actions Bot requested a review from aduth December 2, 2026 15:36
@ciampo ciampo changed the title Snackbar: Use the adaptive outer shadow token Snackbar: Use WPDS shadow tokens, improve theme inheritance Dec 2, 2026

@aduth aduth 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.

👍

Comment on lines +73 to +78

// Button's pressed color comes from the surrounding theme, which is light
// behind the dark snackbar.
&:active {
color: $white;
}

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.

I gather that we may be able to address this more holistically depending where we end up with #87834, and this still feels correct insofar as we were previously relying on the admin background incidentally being dark the same way that the snackbar is, but it does feel a bit odd that we have to patch in these forced colors for button, spinner, etc. In the current arrangement I would rather expect a nested set of ThemeProviders, one that establishes the background context for things like focus rings in how the snackbar is shown atop content, and one for the Snackbar and its contents itself (with a black background).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed that nested providers are the cleaner model: an outer one for the content behind the snackbar (shadow, focus ring) and an inner dark one for its contents, which would replace the :active and spinner patches. The inner seed depends on how #87834 lands, so I'd rather do it there than pick a dark seed now.

For example, if we landed on Option C in #87834, the implementation could be simplified considerably

ciampo and others added 11 commits December 2, 2026 23:11
Render snackbars in edit-site and boot under the content ThemeProvider,
since they float over the content and not over the admin color scheme
background. Then move Snackbar from $elevation-small to
--wpds-shadow-outer-sm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On mobile, the sidebar fills the screen on routes without mobileContent, such as Navigation. Snackbars there now inherit the admin color scheme, so their focus ring keeps its contrast against the sidebar.
Nested providers inherit the admin scheme's primary color, so the content surfaces and snackbars only need the background seed.
Snackbars are fixed to the viewport, so on desktop they can float over the admin background instead of the content. Their focus ring is then tuned for light content.
Button's pressed color comes from the surrounding theme. Under a light provider it turned the action text dark on the dark snackbar.
The Spinner color comes from the surrounding theme. Under a light provider it was gray on the dark snackbar.
…out a canvas

On mobile, a route without a preview shows the admin background in edit mode, such as Patterns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ciampo
ciampo merged commit a579f88 into trunk Dec 2, 2026
83 of 84 checks passed
@ciampo
ciampo deleted the update/snackbar-adaptive-shadow branch December 2, 2026 22:51
@github-actions github-actions Bot added this to the Gutenberg 24.7 milestone Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Boot /packages/boot [Package] Components /packages/components [Package] Edit Site /packages/edit-site [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