Skip to content

Theme: Add shadow tokens that adapt to the background seed - #87287

Merged
ciampo merged 25 commits into
trunkfrom
add/theme-luminance-elevation
Dec 1, 2026
Merged

ciampo merged 25 commits into
trunkfrom
add/theme-luminance-elevation

Conversation

@jameskoster

@jameskoster jameskoster commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What?

Part of #75266

Adds --wpds-shadow-outer-xs, -sm, -md and -lg tokens whose strength adapts to the ThemeProvider background, and uses them for the shadows in @wordpress/ui and @wordpress/components.

Why?

The shadows are semi-transparent black, so they almost disappear on dark backgrounds. Popovers, menus and dialogs lose their depth in dark themes.

How?

  • The tokens use the same layers as the $elevation-* Sass variables, so the default background looks exactly like trunk. Other light backgrounds get a slightly stronger shadow, for example ×1.1 on #f0f0f0.
  • On darker backgrounds, ThemeProvider makes the shadows stronger, up to 5×, so they stay visible. Near black, a shadow has little left to darken, so it still shows less.
  • Snackbar keeps $elevation-small for now. In the site editor it floats over light content from inside a dark provider, so the token would make its shadow too strong.
  • New docs explain which shadow to use for each kind of surface, and what to do when a layer floats over a different background than its provider's.
How the strength is calculated
  • Curve: a black shadow darkens a light color much more than a dark one. ThemeProvider scales every layer's opacity so the shadow darkens the background by the same perceived amount (CIELAB ΔL*) as it darkens white: about 1.3× for #bbbbbb, 1.9× for #777777 and 3.2× for #3d3d3d. Near black no scale can reach that, so it stops at 5×, and no single layer goes above 25%.
  • Which color: the scale uses the provider's neutral surface color (--wpds-color-background-surface-neutral), not the raw seed. The background ramp can move that color away from the seed: a #777777 seed generates #9d9d9d. For the default seed the two are the same.
  • Where it runs: the opacity is computed in JS (packages/theme/src/shadow.ts) and output with the color tokens whenever a color seed is set. Without a seed, the static values in tokens/shadow.json apply.
  • Tests: they check that the runtime layers match tokens/shadow.json, that the default output matches the static tokens, and that two seeds with the same surface color get the same shadow.
Affected components
  • @wordpress/ui: AlertDialog, Autocomplete, Combobox, Dialog, Drawer, Menu, Popover, Select, Switch and Tooltip.
  • @wordpress/components: CustomSelectControl, FormToggle, Menu, Modal, Popover, ResizableBox and Tooltip. Snackbar keeps $elevation-small (see follow-up 4).
  • Tooltip: Tooltip.Popup renders inside its own dark ThemeProvider, but its shadow falls on the page behind it. The positioner reads --wpds-shadow-outer-sm outside that provider, so tooltips on a light page keep trunk's shadow.
  • Visible change: none on the default background. Portaled popovers, menus and dialogs read the root provider, so in wp-admin they look the same as trunk until an app sets a darker root seed.
Docs and naming
  • The token reference has a new Raising a surface section: which outer shadow to use for each kind of surface. It covers only shadows, because we're still working out which elevation pattern to recommend.
  • The theme README has a Shadows section for the two layouts where a shadow falls on a different background than its provider's, including portaled layers.
  • The base-styles README maps each $elevation-* variable to its token, and the Storybook elevation page points to both. A comment in _variables.scss tells new code to prefer the tokens. The variables keep their static values (see follow-up 3).
  • Naming: these were called --wpds-elevation-* earlier, but Theme: Remove elevation tokens #80099 removed elevation tokens because they were only shadows. If elevation needs another part later, it gets a token of its own type. The outer segment says these are outer box shadows, as the CSS spec calls them, and leaves room for inner (inset) shadow tokens later.
  • Strokes: Popover and Menu keep their 1px --wpds-color-stroke-surface-neutral stroke. The docs don't tell consumers to pair a shadow with a stroke, because we haven't decided whether raised surfaces should have one (see follow-up 2). The Shadow stories show only the shadows. An earlier top-edge highlight was removed after review, and Try: Hide the Popover and Menu stroke and strengthen light elevation #87288 (hiding the stroke instead) was closed.

Testing Instructions

  1. Run npm run storybook:dev.
  2. Open Design System > Theme > Shadow > Background Sweep. The shadows should look about equally strong from white to dark gray, and the white row should match trunk.
  3. Open Stacked Overlays: Light and Stacked Overlays: Dark. They show a content frame (xs) with a menu and a submenu (md) open over it. Each layer should stay distinct from the one below it. On the dark background the shadows are at the strength cap, so they separate the layers less.
  4. Open the @wordpress/ui Popover, Menu, Dialog and Tooltip stories, and the @wordpress/components Modal, Popover and Tooltip stories. They should match trunk on the default background, and still look raised when you switch the Storybook theme to a dark background.
  5. In the site editor, trigger a snackbar (for example, save a template). Its shadow should match trunk.
More checks in the Shadow story
  • In Background Sweep, the #777777 row should read "surface #9d9d9d · shadow scale ×1.5".
  • In Default, pick a few colors with the picker, including mid grays and saturated colors. The story should keep rendering.

Testing Instructions for Keyboard

No interaction changes. The affected components open and close with the keyboard as before.

Screenshots

Before After
shadow-before-trunk Background Sweep with shadows only

The After screenshot was taken before the rename, so its cards show the old --wpds-shadow-* names.

Follow-ups

1. Tooltip with a custom positioner

Tooltip only reads the outer shadow on its own positioner. A custom element passed to the positioner slot resolves the shadow inside the popup's dark provider, so it gets the 5× shadow on a light page. Removing the provider in 1a fixes this.

2. Strokes on raised surfaces today
4. Snackbar

In edit-site and boot (together, for site editor parity), render SnackbarNotices under the light content provider, for example by wrapping it in <ThemeProvider color={ CONTENT_COLOR }>. It renders in three places: edit-site/src/components/layout/index.jsx, boot/src/components/root/index.tsx and boot/src/components/root/single-page.tsx. UploadProgressSnackbar only creates a notice and renders nothing, so it doesn't need to move. Snackbar hard-codes its own colors, but its focus ring uses --wpds-color-stroke-focus, so check the focus ring as well as the shadow.

5. Remaining $elevation-* users

Before moving each one, check which ThemeProvider it renders in and which background it floats over (see the README's Shadows section).

Package File Surface Level Stroke today
components snackbar/style.scss Snackbar sm None (see 2)
edit-site layout/style.scss (3 uses) Resizable content frame, layout areas xs, lg on hover None
block-editor inserter/style.scss Quick inserter popover content xs --wpds-color-stroke-surface-neutral
block-editor block-draggable/style.scss (2 uses) Drag chip sm None (dark chip)
block-editor writing-flow/style.scss Canvas stop hint sm None (dark hint)
editor collaborators-presence/avatar/styles.scss Collaborator avatar xs White ring
editor collab-sidebar/style.scss Selected note md None
grid dashboard-grid/grid.module.scss (8 uses) Drag preview md, xs None
grid dashboard-lanes/lanes.module.scss (8 uses) Drag preview md, xs None
widget-dashboard widget-toolbar/widget-toolbar.module.scss Widget toolbar xs --wpds-color-stroke-surface-neutral-weak
widget-dashboard widgets/widgets.module.scss Widget tile in edit mode xs None

The deprecated __experimentalElevation component is unchanged.

  • Optional: generate the runtime layer table in src/shadow.ts from tokens/shadow.json during the token build, so a shadow change needs one edit instead of two. A test catches the two drifting apart until then.

Use of AI Tools

Written with Claude Code (Claude Opus 5.5): the token design was worked out together, Claude wrote the implementation, tests and story, and I reviewed the result and checked it in Storybook. After review, Claude Code added the surface-based scale, the Snackbar change, the documentation, the story updates and the outer rename, at ciampo's direction.

🤖 Generated with Claude Code

@jameskoster
jameskoster requested a review from a team as a code owner November 23, 2026 17:29
@jameskoster jameskoster added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components [Package] Theme /packages/theme [Package] UI /packages/ui labels Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 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: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jasmussen <joen@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: +3.68 kB (+0.04%)

Total Size: 8.73 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 55.2 kB +31 B (+0.06%)
build/modules/core-fields/attachment.min.js 44.2 kB +31 B (+0.07%)
build/modules/core-fields/post_type_supports.min.js 87.6 kB +6 B (+0.01%)
build/modules/core-fields/wp_block.min.js 32.9 kB +32 B (+0.1%)
build/modules/core-fields/wp_template_part.min.js 39.5 kB +30 B (+0.08%)
build/modules/workflow/index.min.js 42.8 kB +5 B (+0.01%)
build/scripts/block-directory/index.min.js 42.6 kB +26 B (+0.06%)
build/scripts/block-editor/index.min.js 559 kB +66 B (+0.01%)
build/scripts/block-library/index.min.js 433 kB +79 B (+0.02%)
build/scripts/components/index.min.js 358 kB +103 B (+0.03%)
build/scripts/edit-post/index.min.js 45.2 kB +29 B (+0.06%)
build/scripts/edit-site/index.min.js 377 kB +475 B (+0.13%)
build/scripts/editor/index.min.js 574 kB +455 B (+0.08%)
build/scripts/format-library/index.min.js 73.6 kB +19 B (+0.03%)
build/scripts/media-utils/index.min.js 235 kB +673 B (+0.29%)
build/scripts/notices/index.min.js 47.9 kB +57 B (+0.12%)
build/scripts/theme/index.min.js 29.1 kB +445 B (+1.55%)
build/scripts/widgets/index.min.js 65.1 kB +7 B (+0.01%)
build/styles/components/style-rtl.css 18.7 kB +81 B (+0.43%)
build/styles/components/style-rtl.min.css 15.8 kB +59 B (+0.37%)
build/styles/components/style.css 18.8 kB +82 B (+0.44%)
build/styles/components/style.min.css 15.8 kB +64 B (+0.41%)
build/styles/theme/design-tokens-rtl.css 3.6 kB +286 B (+8.64%) 🔍
build/styles/theme/design-tokens-rtl.min.css 1.7 kB +128 B (+8.14%) 🔍
build/styles/theme/design-tokens.css 3.6 kB +286 B (+8.64%) 🔍
build/styles/theme/design-tokens.min.css 1.7 kB +128 B (+8.14%) 🔍

54efc24 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 5cce44f trunk % Change
timeToFirstByte 38.65 ms +16.82% -3.88% 37.6 ms +9.44% -3.99% 2.79%
largestContentfulPaint 60 ms +16.67% -0% 64 ms +6.25% -6.25% -6.25%
lcpMinusTtfb 22.3 ms +8.74% -5.61% 25.3 ms +9.29% -11.66% -11.86%
wpBeforeTemplate 20.15 ms +9.43% -1.69% 19.34 ms +13.7% -2.43% 4.19%
wpTemplate 15.13 ms +8.59% -5.16% 14.44 ms +5.33% -2.22% 4.78%
wpTotal 35.34 ms +18% -3.65% 34.28 ms +10.5% -3.76% 3.09%
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 5cce44f trunk % Change
timeToFirstByte 33.1 ms +9.67% -4.23% 31.35 ms +5.9% -6.54% 5.58%
largestContentfulPaint 62 ms +3.23% -6.45% 56 ms +7.14% -7.14% 10.71%
lcpMinusTtfb 26.85 ms +11.92% -4.66% 24 ms +20.42% -4.38% 11.88%
wpBeforeTemplate 18.42 ms +2.01% -4.07% 16.99 ms +2.3% -1.82% 8.42%
wpTemplate 12.05 ms +5.89% -8.46% 10.24 ms +6.74% -3.42% 17.68%
wpTotal 30.44 ms +9.17% -5.32% 27.46 ms +9.91% -2.4% 10.85%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 5cce44f trunk % Change
mediaProcessingJpeg 236 ms +1.58% -1.97% 224.79 ms +1.26% -2.16% 4.99%
mediaProcessingAvif 3762.73 ms +0.16% -0.93% 3623.84 ms +1.19% -0.85% 3.83%
mediaProcessingJpegToAvif 2658.2 ms +0.19% -1.88% 2566.63 ms +0.71% -1.53% 3.57%

media-upload

Metric 5cce44f trunk % Change
jpegUploadProcessing 1450.31 ms +1.71% -0.61% 1442.8 ms +1.2% -0.7% 0.52%
pngUploadProcessing 203.87 ms +3.21% -6.47% 210.43 ms +4.69% -4.82% -3.12%
largeJpegUploadProcessing 1449.5 ms +0.83% -1.19% 1433.65 ms +1% -1.02% 1.11%
multipleImageUploadProcessing 1505.35 ms +1.04% -0.85% 1506.14 ms +1.36% -1.64% -0.05%

post-editor

Metric 5cce44f trunk % Change
serverResponse 322.77 ms +6.73% -7.01% 328.19 ms +2.58% -11.75% -1.65%
firstPaint 310.94 ms +12.27% -7.22% 307 ms +9.72% -1.57% 1.28%
domContentLoaded 627.32 ms +2.41% -1.23% 633.87 ms +1.11% -1.24% -1.03%
loaded 628.17 ms +2.39% -1.24% 634.75 ms +1.09% -1.26% -1.04%
firstContentfulPaint 358.49 ms +2.11% -2.62% 361.04 ms +1.81% -3.61% -0.71%
firstBlock 1692.41 ms +1.12% -2.65% 1730 ms +1.66% -1.41% -2.17%
type 14.62 ms +10.05% -10.47% 14.76 ms +3.05% -6.5% -0.95%
typeWithoutInspector 14.52 ms +2.41% -8.95% 14.9 ms +3.22% -12.15% -2.55%
typeWithTopToolbar 18.16 ms +3.47% -8.65% 17.73 ms +9.14% -8.46% 2.43%
typeContainer 6.82 ms +5.57% -13.2% 6.65 ms +11.58% -9.62% 2.56%
focus 85.33 ms +4.91% -2.36% 79.23 ms +2.7% -3.65% 7.7%
firstFocus 209.51 ms +0% -0% 202.58 ms +0% -0% 3.42%
selectAll 308.45 ms +0.53% -2.88% 292.75 ms +1.04% -2.98% 5.36%
undo 23.47 ms +6.05% -4.81% 23.33 ms +8.87% -2.4% 0.6%
listViewOpen 31.65 ms +5.43% -8.56% 29.38 ms +6.23% -4.49% 7.73%
inserterOpen 32.2 ms +3.04% -9.07% 32.15 ms +4.17% -9.95% 0.16%
inserterHover 8.92 ms +10.65% -5.04% 9.12 ms +5.04% -6.91% -2.19%
inserterSearch 7.12 ms +7.87% -9.41% 6.83 ms +3.07% -1.46% 4.25%
loadPatterns 502.17 ms +0.71% -1.74% 493.95 ms +10.56% -2.49% 1.66%
wpTotal 314.25 ms +6.17% -7.18% 319.55 ms +2.34% -12.35% -1.66%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 5cce44f trunk % Change
serverResponse 464.08 ms +0.44% -6.66% 426.24 ms +9.65% -0.14% 8.88%
firstPaint 439.46 ms +3.98% -12.13% 449.12 ms +2.44% -16% -2.15%
domContentLoaded 837.99 ms +3.4% -1.44% 820.76 ms +1.46% -0.72% 2.1%
loaded 839.19 ms +3.37% -1.45% 821.56 ms +1.5% -0.71% 2.15%
firstContentfulPaint 466.12 ms +7.73% -3.93% 459.38 ms +0.61% -0.52% 1.47%
firstBlock 2618.22 ms +4.3% -2.27% 2537 ms +0.96% -0.32% 3.2%
type 16.53 ms +11.25% -3.87% 16.6 ms +6.69% -8.8% -0.42%
navigate 111.53 ms +4.78% -5.8% 108.47 ms +5.73% -1.39% 2.82%
loadPatterns 1589.91 ms +3.47% -2.76% 1682.32 ms +4.6% -9% -5.49%
loadPages 921.77 ms +2.14% -1.64% 937.9 ms +5.59% -1.57% -1.72%
wpTotal 454.74 ms +0.42% -6.83% 416.76 ms +9.9% -0.15% 9.11%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

54efc24 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.

As a user I want to be able to create a navigation overlay for a specific navigation block in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: /(Editor publish|Save panel)/ }).getByRole('button', { name: 'Save', exact: true })

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:48:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:91:4

54efc24 Run

@jameskoster

Copy link
Copy Markdown
Contributor Author

For the open question about the Popover and Menu stroke: #87288 is a draft on top of this PR that hides the stroke (keeping it in forced-colors mode) and raises the minimum shadow opacity from 0.05 to 0.08, so the two can be compared in Storybook.

@jameskoster

Copy link
Copy Markdown
Contributor Author

Shadows: 5% on white, about 19% on #777777, 27% on #1e1e1e, 30% on black

For @WordPress/gutenberg-design the min/max of this is easily adjusted. Please feel free to check out the branch, adjust, and push suggestions.

@ciampo ciampo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for picking this up! At a high level, I feel like we now have so many PRs all happening at once, maybe it would be better to discuss how we want to prioritise DS work? I remember you said you were working on high contrast too, for example?


Apart from that, I'll leave some initial thoughts. The overall approach (box shadow values depending on bg seed) sounds like a good start. A couple of bigger-picture things before we tune values:

  1. I'd keep the stroke and drop the top highlight. On dark backgrounds a black shadow has very little left to darken, so the lighter stroke ends up doing most of the work. I looked at a few major design systems, and most of them keep a lighter stroke on popovers in dark mode. None of them uses a top highlight. Keeping the stroke also lines up with the surface + edge + shadow idea from #75266, and dropping the highlight gets rid of the doubled top edge.
  2. I'd reconsider the --wpds-elevation-* name. We removed these tokens in #80099, partly because the name didn't fit: they're really just shadows. I'd either call them that (something like --wpds-shadow-*), or design elevation as a whole, with surface, border and shadow tokens that work together.
Numbers and references

CIELAB lightness difference (ΔL*) from the surface, using the PR's curve and our generated ramps:

Seed Shadow 100% black shadow Stroke Highlight
#ffffff 4.4 100 11.5 0
#777777 11.6 64.7 11.4 1.9
#1e1e1e 4.1 11.3 7.0 9.0
#000000 0 0 10.2 11.2

Lighter strokes in dark mode: Primer (0 0 0 1px #3d444d), Atlassian (0 0 0 1px #BDBDBD1F), Radix (gray-a6) and Spectrum (popover-border-opacity 0 in light, 1.0 in dark). Primer and Spectrum add the stroke only for dark mode. Fluent and Material 3 have no stroke and use lighter surfaces instead.

Smaller points:

  • Menus from the site editor sidebar (dark seed) keep their 27% shadow when they spill over the light content area, so they look about 5× darker there. Might be worth a quick look.
  • grid, edit-site, block-editor and editor still use the old static $elevation-* variables. Maybe a follow-up issue?
  • Tiny one: the ELEVATION_LEVELS JSDoc points to test/elevation.ts, but the file is test/elevation.test.ts.

Comment thread packages/theme/src/elevation.ts Resolved
@jameskoster

Copy link
Copy Markdown
Contributor Author

Fair, I'll remove the highlight to discuss separately.

@jameskoster jameskoster changed the title Theme: Adapt elevation tokens to the background seed Theme: Add shadow tokens that adapt to the background seed Nov 23, 2026
@jameskoster

jameskoster commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Prioritisation is probably something we should work on as a group. I'd consider this low prio fwiw.

@jasmussen

Copy link
Copy Markdown
Contributor

I think I agree with the principle: the darker the background, the higher the opacity, which I understand is the only shadow property changing.

An interesting question, should the colour of the shadow also change based on background tint? Not something to explore here, but something to ponder. E.g. if the background is theme coloured, seeding the shadow with that might be nice too.

@jameskoster

Copy link
Copy Markdown
Contributor Author

I think tinted shadows are worth exploring in a follow-up. They already pick up the background a little, but the pure black shadows can look a bit muddy on saturated backgrounds. Using a dark shade of the seed's own hue would look richer. That said, shadows don't always cast on the seed background. Especially in the editor menus and such can appear over images and basically any color imaginable. It's fine in the default theme which has a neutral background seed, but tinted shadows could look odd these cases.

@ciampo

ciampo commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

The highlight removal, the rename and the new curve all look good to me. I re-ran some checks, and md now darkens the background by about the same amount from white down to #777777 (roughly 11.8 ΔL*), so I'll resolve that thread.

A few things before this lands:

Tooltips get a much stronger shadow. Tooltip.Popup in @wordpress/ui renders inside its own ThemeProvider with a #1e1e1e background, so --wpds-shadow-sm resolves to the dark-seed value on every page. On a light page that's 25/20/15/10% layers where trunk has 5/4/3/2%. Could we read the token outside that provider? One way is a private property on .positioner, such as --_wp-ui-tooltip-shadow: var(--wpds-shadow-sm), that .popup then uses.

What should the token follow? The tooltip is one case of a broader mismatch. The token follows the provider around the surface, but the shadow falls on whatever is behind it. SnackbarNotices sits inside the dark themeColors provider in the site editor and boot layouts but floats over the light content, so I'd expect it to get the 5× shadow there. I read that from the code and haven't checked it in a browser.

I also need to correct my earlier point about sidebar menus. Portaled menus and popovers read the light root provider, so they look the same as trunk even when opened from the dark sidebar. That also means most popovers, menus and dialogs in wp-admin won't change with this PR until an app has a dark root seed.

Should snackbars read the content seed, or do we accept this for now? Either way, I think the README should say that the token assumes the surface sits on its provider's background.

Description. It still covers the two-layer version, including the "Visible change" note, the 9% and 16% figures, and probably the screenshots. Could you refresh it now that the tokens match $elevation-* on light backgrounds?

Let's also make sure to track the follow-up refactor across the rest of the repo

@jameskoster

Copy link
Copy Markdown
Contributor Author

Probably not the place to discuss it but should we revisit the decision to render Tooltip in it's own ThemeProvder? I guess this extends to Snackbars too; should they remain high contrast? To me this feels like a bit archaic.

The screenshots are accurate.

@jameskoster
jameskoster force-pushed the add/theme-luminance-elevation branch from 4b52a1e to 49fe0a1 Compare November 27, 2026 16:54
@jameskoster

Copy link
Copy Markdown
Contributor Author

Applied the changes you suggested and updated the PR description.

Once this merges, I'll open follow-ups for:

  1. moving grid, edit-site, block-editor and editor from $elevation-* to the --wpds-shadow-* tokens;
  2. deciding whether tooltips and snackbars should stay inverted, and if they do, how their shadows should read the background behind them;
  3. Joen's idea of tinting the shadows with the background seed.

@ciampo

ciampo commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Probably not the place to discuss it but should we revisit the decision to render Tooltip in it's own ThemeProvder? I guess this extends to Snackbars too; should they remain high contrast? To me this feels like a bit archaic.

Agreed that the ThemeProvider wrapper should go. It was a workaround from when Tooltip was first added in #74625, because we had no token for an always-dark surface.

What replaces it is a design decision first. I see two options:

  • Permanently dark. The tooltip stays dark in every theme. That's what we have today.
  • Inverted. The tooltip is dark on light themes and light on dark themes, so it always contrasts with the page. That would be a departure from the current design, and what your gut is suggesting.

The color ramps already generate the colors for both. What's missing is dedicated semantic tokens. The always-dark colors (bgFillDark / fgFillDark) aren't exposed at all, and the inverted ones are only exposed through the interactive-neutral-strong tokens, which are meant for controls.

So the next steps would be:

  1. Decide on the design.
  2. Add the semantic tokens that design needs.
  3. Update Tooltip to use them and remove the ThemeProvider.

The same decision should cover Snackbar. This probably deserves its own issue so it doesn't hold up this PR.

@jameskoster

Copy link
Copy Markdown
Contributor Author

Actually I think the tooltip should just follow the theme—no fancy inversion or exceptions. But yes this will need to be discussed in a dedicated issue.

Any other changes to make in this PR do you think?

@ciampo

ciampo commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

I pushed a few changes (mostly fixes and enhancement that I found while reviewing), and updated the description with a list of follow-ups:

  • Shadows now scale for the surface color, not the seed. The background ramp can shift --wpds-color-background-surface-neutral away from the seed (#777777 becomes #9d9d9d), so the shadow was tuned for a color that isn't actually on screen. Nothing changes for the default seed.
  • Snackbar is back on $elevation-small. In the site editor it sits inside the dark admin provider but floats over light content, so it was getting a 5× shadow. The proper fix is in the layouts, so I listed it as a follow-up.
  • Docs. There's a new "Raising a surface" section in the token reference (which background, stroke and shadow go together), and a "Shadows" section in the theme README for layers that float over a different provider's background.
  • Story and tests. The story uses a native color picker, because the Storybook control could send colors that crash the provider. Popover, menu, dialog and drawer cards show the surface stroke those components draw. New tests keep SHADOW_LEVELS in sync with shadow.json.

I kept the --wpds-shadow-* naming. Strokes were never "elevation" tokens either, so elevation is really the pattern that combines them.

Before After
Background Sweep before these changes Background Sweep with the strokes the components draw

The #777777 row is a bit lighter now, and the dialog and drawer cards also show their stroke.

Assuming Tooltip and the other follow-ups get tackled separately, do you think this is ready?

@ciampo

ciampo commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Update: after chatting with @jameskoster , we agreed to ship the "safe" version of this PR soon (ie adding shadow-outer tokens); Jay is going to refine some storybook examples and then it should be ready to go.

Separately, we prepared a list of follow-ups that we're going to work on; the list is in the PR description and it involves both changes / improvements in the repo, and next steps / iteration on the elevation work, specifically on how to best visually show elevation on dark surfaces.

ciampo and others added 12 commits December 1, 2026 13:30
- Link to the token reference with a full URL, so the link also works in
  the Storybook copy of the README.
- Stop claiming shadows look the same on any background. They strengthen
  up to a cap, and near black the stroke separates the surface.
- Restore the formatting of README sections this PR doesn't change,
  including a JSON example that had gained trailing commas.
The parity test compared rounded CSS output, so a small change to a layer
in `shadow.json` could pass without updating `SHADOW_LEVELS`. Compare the
raw layers too.
Light backgrounds other than the default already get a slightly stronger
shadow, for example `#eeeeee` gets a scale of 1.1.
`ThemeProvider` doesn't paint a background. It generates
`--wpds-color-background-surface-neutral` from the seed and scales the
shadows for that color. Use that one description across the docs,
changelog, story, and comments, and state that the shadows match the
backdrop when the area behind a surface uses that token.
`AlertDialog.Popup` uses the Dialog popup styles, so it gets the same
adaptive shadow.
Wrapping a portaled popup in a `ThemeProvider` doesn't change its tokens,
because the portal mounts it outside the provider's element. Point those
consumers to the portal container instead.
The switch thumb's border is the control's accessible outline, not part
of its elevation. Drawn on a story card, its dark interactive stroke
suggested that `xs` surfaces get a heavy border. Show no stroke for `xs`,
use content frames as the main example, and say in the token reference
that controls keep their own border.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The name now says the tokens are outer box shadows, which leaves room for
inner (inset) shadow tokens later.

Also loosen the elevation guidance: the docs no longer tell consumers to
pair a shadow with a stroke, because the design system hasn't decided
whether raised surfaces should have one. The Shadow stories show only the
shadows, and gain stacked overlay examples on light and very dark
backgrounds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Show a content frame with a menu and a submenu over it, using
placeholder lines instead of labels and token names. Drop the dialog,
which isn't accurate without its scrim, and the tooltip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An earlier commit reformatted every list item in the components, ui, and
theme changelogs from `-   ` to `- `, which conflicted with trunk on
every rebase. Keep trunk's formatting and change only this PR's entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jameskoster
jameskoster force-pushed the add/theme-luminance-elevation branch from fd41c52 to c6806d3 Compare December 1, 2026 13:31
Comment thread packages/base-styles/_variables.scss Outdated
Comment on lines 73 to 75
*
* Prefer the matching --wpds-shadow-outer-* design tokens in new code.
*/

This comment was marked as duplicate.

Comment thread packages/base-styles/_variables.scss Resolved
ciampo and others added 2 commits December 1, 2026 17:27
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 🚀

Let's merge and iterate per the "follow-up" section in the PR description

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

Labels

[Package] Base styles /packages/base-styles [Package] Components /packages/components [Package] Theme /packages/theme [Package] UI /packages/ui [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants