Skip to content

Base Styles: Move Gutenberg from $elevation-* to the shadow tokens - #87894

Merged
ciampo merged 8 commits into
trunkfrom
update/elevation-variables-to-shadow-tokens
Dec 3, 2026
Merged

ciampo merged 8 commits into
trunkfrom
update/elevation-variables-to-shadow-tokens

Conversation

@ciampo

@ciampo ciampo commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What?

Follow-up to #87287 (follow-ups 3 and 5). Part of #75266.

Disallows the $elevation-* Sass variables in Gutenberg with Stylelint and moves every Gutenberg use to the --wpds-shadow-outer-* tokens. The variables keep their values, and their public deprecation is left for a later release. The extensible site editor's canvas moves to the same token as the site editor frame.

Why?

#87287 asked what to do with the $elevation-* variables. I compared three options:

Option Effect on code outside Gutenberg
A. Alias each variable to its token Switches to the adaptive shadow with no check. A surface inside a dark provider that floats over light content gets a shadow up to 5× too strong, as Snackbar did in #87287.
B. Keep the values static, migrate and lint Gutenberg (chosen) No change in behavior.
C. Remove Breaks builds, because @wordpress/base-styles is published.

We chose B because the token is only right when a surface floats over its own provider's background. Someone has to check that for each surface, so a blanket alias isn't safe. B lets us check each Gutenberg surface and leaves shadows outside Gutenberg alone. #87492 migrated and linted the $radius-* variables the same way. The public deprecation and removal will ship later, together with the other design system variables, so consumers migrate once.

How?

  • The variables and their $shadow-popover and $shadow-modal aliases don't change. The base-styles changelog and README don't announce a deprecation yet.
  • A Stylelint rule flags them in Gutenberg and names the matching token.
  • Every Gutenberg use moves to the token. Only the two site editors change visibly: the frame (edit-site) and the canvas (boot) get a stronger shadow on dark admin color schemes. On light schemes the boot canvas gets slightly softer, to match the frame. The root providers of the post editor and both site editors give the tokens their default values, so popovers and drag chips at the document body don't change.
  • The boot canvas used its own 0 1px 3px shadow. It now uses --wpds-shadow-outer-xs, like the edit-site frame. The canvas renders inside the content provider, but its shadow falls on the admin background, so .surfaces resolves the token under the admin provider and passes it down in --wp-boot-canvas-shadow.
Provider check for each surface
Package Surface Renders under Visible change
edit-site Content frame, layout areas Admin color scheme provider, over the admin background Stronger shadow on dark schemes
boot Canvas Content provider; the token is read on .surfaces, under the admin provider Four-layer xs shadow instead of 0 1px 3px; stronger on dark schemes
block-editor Quick inserter Root provider None
block-editor Drag chip Root provider (the clone is appended to the document body) None
block-editor Canvas stop hint Canvas iframe (static tokens) or the editor's provider None
editor Selected note, collaborator avatar, canvas cursor Content provider, or canvas iframe None
grid Drag preview (DragOverlay renders inline) Consumer's provider None on the default background
widget-dashboard Widget toolbar, tile in edit mode Boot content provider (#fcfcfc) None
Other details
  • This PR and Tooltip, Snackbar: Follow the theme instead of staying dark #87863 both change the drag chip and canvas stop hint shadows. Both use --wpds-shadow-outer-sm, so the PRs don't depend on each other, and the merge conflict is easy to resolve.
  • grid and widget-dashboard no longer import @wordpress/base-styles, so their unused dev dependency is removed.

Testing Instructions

  1. Run npm run lint:css. It passes.
  2. Add box-shadow: $elevation-small; to an SCSS file in packages/ and run npm run lint:css. It asks you to avoid the variable and names var(--wpds-shadow-outer-sm).
  3. Pick the Coffee or Blue admin color scheme in Users > Profile, and open Appearance > Editor. The frame's shadow is easier to see than on trunk.
  4. Pick the Light scheme. The frame's shadow is about the same as on trunk.
  5. Go to Settings > Gutenberg, enable Extensible Site Editor, and open Appearance > Editor again. On Coffee, the canvas shadow is a bit stronger than on trunk. On Light, it's a bit softer, and matches the site editor frame.
  6. In a post, drag a block and open the quick inserter. The drag chip and the inserter match trunk.

Testing Instructions for Keyboard

No interaction changes.

Screenshots or screencast

Bottom-left corner of the site editor frame, Coffee scheme, 1440×900 at 2×.

Before After
Coffee scheme, trunk: the frame edge has almost no shadow Coffee scheme, this branch: a soft shadow along the frame's bottom edge
Modern and Blue schemes
Before After
Modern scheme, trunk Modern scheme, this branch
Blue scheme, trunk Blue scheme, this branch

On Modern the background is near black, so the shadow stays hard to see even at full strength.

Extensible site editor canvas (Light, Coffee and Modern)

The canvas border carries most of the edge, so the change is subtle. Computed shadow before: 0 1px 3px rgba(0, 0, 0, 0.1) on every scheme. After: the xs layers at about ×1.2, ×2.5 and ×5 strength.

Before After
Light scheme, trunk: canvas with a single-layer shadow Light scheme, this branch: canvas with the softer xs shadow
Coffee scheme, trunk Coffee scheme, this branch: slightly stronger shadow
Modern scheme, trunk Modern scheme, this branch

Use of AI Tools

Written with Claude Code (Claude Opus 5.5), and reviewed with Codex (GPT-6.2 Astra). Claude compared the options, made the change and took the screenshots. I review it before marking it ready.

🤖 Generated with Claude Code

@github-actions github-actions Bot added [Package] Editor /packages/editor [Package] Block editor /packages/block-editor [Package] Edit Site /packages/edit-site [Package] Base styles /packages/base-styles [Package] Grid /packages/grid [Package] Widget Dashboard /packages/widget-dashboard labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 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: mirka <0mirka00@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 or WordPress.org 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: +59 B (0%)

Total Size: 8.86 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 54.9 kB +76 B (+0.14%)
build/scripts/editor/index.min.js 579 kB +6 B (0%)
build/styles/block-editor/style-rtl.css 20.7 kB -50 B (-0.24%)
build/styles/block-editor/style-rtl.min.css 17.6 kB -36 B (-0.2%)
build/styles/block-editor/style.css 20.8 kB -49 B (-0.24%)
build/styles/block-editor/style.min.css 17.6 kB -35 B (-0.2%)
build/styles/edit-site/style-rtl.css 21.7 kB +10 B (+0.05%)
build/styles/edit-site/style-rtl.min.css 17.7 kB +15 B (+0.08%)
build/styles/edit-site/style.css 21.8 kB +9 B (+0.04%)
build/styles/edit-site/style.min.css 17.7 kB +14 B (+0.08%)
build/styles/editor/style-rtl.css 32.8 kB +24 B (+0.07%)
build/styles/editor/style-rtl.min.css 28.5 kB +26 B (+0.09%)
build/styles/editor/style.css 32.9 kB +23 B (+0.07%)
build/styles/editor/style.min.css 28.5 kB +26 B (+0.09%)

c7db021 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric c30aa72 trunk % Change
timeToFirstByte 57.8 ms +6.92% -2.51% 57.15 ms +5.42% -3.24% 1.14%
largestContentfulPaint 88 ms +4.55% -4.55% 92 ms +4.35% -8.7% -4.35%
lcpMinusTtfb 29.5 ms +6.27% -6.27% 32.3 ms +15.33% -11.61% -8.67%
wpBeforeTemplate 29.8 ms +15.03% -1.98% 29.96 ms +8.51% -3.27% -0.53%
wpTemplate 22.87 ms +3.54% -5.29% 22.54 ms +6.34% -1.33% 1.46%
wpTotal 54.08 ms +6.84% -2.96% 53.13 ms +6.14% -3.59% 1.79%
wpMemoryUsage 7.76 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric c30aa72 trunk % Change
timeToFirstByte 47.05 ms +7.55% -2.02% 47.4 ms +4.75% -1.16% -0.74%
largestContentfulPaint 84 ms +2.38% -4.76% 84 ms +2.38% -4.76% 0%
lcpMinusTtfb 34.6 ms +3.9% -2.02% 34.35 ms +6.11% -2.18% 0.73%
wpBeforeTemplate 27.16 ms +4.09% -1.69% 27.11 ms +3.76% -0.89% 0.18%
wpTemplate 16.68 ms +4.38% -4.02% 17.2 ms +1.28% -4.3% -3.02%
wpTotal 43.86 ms +7.18% -1.76% 44.36 ms +4.6% -1.47% -1.13%
wpMemoryUsage 6.47 MB +0% -0% 6.43 MB +0% -0% 0.55%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric c30aa72 trunk % Change
mediaProcessingJpeg 399.97 ms +0.47% -0.13% 398.89 ms +0.67% -0.54% 0.27%
mediaProcessingAvif 6144.65 ms +0.04% -0.3% 6152.83 ms +0.16% -0.01% -0.13%
mediaProcessingJpegToAvif 4229.44 ms +0.21% -0.25% 4250.46 ms +0.07% -0.34% -0.49%

media-upload

Metric c30aa72 trunk % Change
jpegUploadProcessing 1982.45 ms +1.72% -23.17% 1495.96 ms +1.63% -0.58% 32.52%
pngUploadProcessing 266.08 ms +4.46% -3.5% 274.66 ms +3.48% -2.55% -3.12%
largeJpegUploadProcessing 1506.65 ms +28.02% -1.77% 1955.79 ms +1.15% -22.1% -22.96%
multipleImageUploadProcessing 2083.06 ms +0.77% -1.02% 2065.62 ms +1.3% -5.48% 0.84%

post-editor

Metric c30aa72 trunk % Change
serverResponse 489.01 ms +1.23% -1.6% 480.64 ms +3.5% -0.35% 1.74%
firstPaint 391.96 ms +12.89% -2.9% 439.33 ms +2.21% -11.8% -10.78%
domContentLoaded 821.68 ms +0.54% -0.79% 817.51 ms +3.27% -2.04% 0.51%
loaded 822.94 ms +0.54% -0.77% 818.88 ms +3.31% -2.03% 0.5%
firstContentfulPaint 464.03 ms +1.59% -0.5% 454.56 ms +6.3% -2.07% 2.08%
firstBlock 2214.3 ms +0.35% -0.16% 2214.6 ms +0.51% -0.71% -0.01%
type 17.18 ms +14.73% -6.81% 17.09 ms +7.78% -8.6% 0.53%
typeWithoutInspector 17.66 ms +3.68% -14.33% 17.33 ms +6.52% -7.04% 1.9%
typeWithTopToolbar 22.95 ms +4.53% -5.45% 22.68 ms +14.15% -4.01% 1.19%
typeContainer 8.67 ms +4.27% -6.81% 8.68 ms +3% -12.21% -0.12%
focus 103.92 ms +6.71% -3.34% 98.11 ms +1.89% -4.71% 5.92%
firstFocus 258.28 ms +0% -0% 261.88 ms +0% -0% -1.37%
selectAll 404.64 ms +4.37% -0.9% 402.46 ms +0.73% -5.06% 0.54%
undo 28.82 ms +5.59% -3.99% 28.02 ms +8.32% -2.71% 2.86%
listViewOpen 38.2 ms +4.21% -12.25% 37.83 ms +4.31% -8.99% 0.98%
inserterOpen 41.39 ms +14.21% -12.76% 39.9 ms +4.74% -5.31% 3.73%
inserterHover 11.48 ms +6.36% -8.28% 10.86 ms +15.93% -10.5% 5.71%
inserterSearch 8.3 ms +4.1% -1.69% 8.42 ms +8.31% -13.9% -1.43%
loadPatterns 627.22 ms +8.88% -2.2% 628.58 ms +8.72% -2.9% -0.22%
wpTotal 478.78 ms +1.14% -1.52% 471.04 ms +3.56% -0.35% 1.64%
wpMemoryUsage 14.86 MB +0% -0% 14.82 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric c30aa72 trunk % Change
serverResponse 302.35 ms +5.99% -5.74% 321.08 ms +2.73% -0.47% -5.83%
firstPaint 308.21 ms +20.6% -3.81% 372.05 ms +3% -3.59% -17.16%
domContentLoaded 664.05 ms +0.91% -0.73% 663.42 ms +1.24% -0.79% 0.09%
loaded 665.1 ms +0.9% -0.74% 664.49 ms +1.24% -0.78% 0.09%
firstContentfulPaint 370.93 ms +0.79% -0.77% 373.08 ms +2.72% -1.13% -0.58%
firstBlock 2050.79 ms +1.2% -0.89% 2037.72 ms +0.93% -0.85% 0.64%
type 15.44 ms +2.85% -7.25% 15.41 ms +5.78% -7.53% 0.19%
navigate 104.1 ms +2.82% -3.29% 98.78 ms +2.68% -5.88% 5.39%
loadPatterns 1254.73 ms +6.98% -18.92% 1257.96 ms +1.73% -3.17% -0.26%
loadPages 1009.69 ms +3.27% -1.83% 1021.89 ms +1.26% -8.66% -1.19%
wpTotal 294.06 ms +6.15% -5.94% 312.7 ms +2.81% -0.43% -5.96%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

c7db021 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.

Navigates the items list via UP/DOWN 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:  getByLabel('Page Two')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByLabel('Page Two') with timeout 5000ms
  - waiting for getByLabel('Page Two')
    14 × locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-203-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-203-label" aria-describedby="view-list-0-203-description"></button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:146:49
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":23,"sizeSlug":"full","linkDestination":"none"} -->
+ <figure class="wp-block-image size-full"><img src="http://localhost:8891/wp-content/uploads/2026/12/1fd33ed0-72e6-4675-be6f-e0ee40f3f780.png" alt="" class="wp-image-23"/></figure>
  <!-- /wp:image -->
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/image.spec.js:432:49

c7db021 Run

@ciampo ciampo changed the title Base Styles: Keep $elevation-* static and use the shadow tokens in Gutenberg Base Styles: Deprecate $elevation-* and use the shadow tokens in Gutenberg Dec 3, 2026
@github-actions github-actions Bot added the [Package] Boot /packages/boot label Dec 3, 2026
@ciampo ciampo self-assigned this Dec 3, 2026
@ciampo ciampo added the [Type] Code Quality Issues or PRs that relate to code quality label Dec 3, 2026
@ciampo
ciampo marked this pull request as ready for review December 3, 2026 11:22
@ciampo
ciampo requested review from aduth and mirka and a balanced review from Copilot December 3, 2026 11:22

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the adaptive shadow-token migration.

No open issues 🎉

What changed in this PR

Deprecates the static Sass elevation variables while preserving their values for external consumers, and migrates Gutenberg surfaces to adaptive shadow tokens.

Changes:

  • Documents deprecations and adds Stylelint enforcement with replacement guidance.
  • Migrates editor and dashboard shadows, aligning both site editors with the admin background.
  • Removes unused base-styles dependencies and updates changelogs.
File Description
tools/​stylelint/​config.js Rejects deprecated shadow variables and suggests tokens.
packages/​widget-dashboard/​src/​components/​widgets/​widgets.module.scss Uses a token for editable tile shadows.
packages/​widget-dashboard/​src/​components/​widget-toolbar/​widget-toolbar.module.scss Uses a token for elevated toolbar shadows.
packages/​widget-dashboard/​package.json Removes unused base-styles dependency.
packages/​widget-dashboard/​CHANGELOG.md Records dashboard shadow migration.
packages/​grid/​src/​dashboard-lanes/​lanes.module.scss Migrates lane drag-preview shadows and animations.
packages/​grid/​src/​dashboard-grid/​grid.module.scss Migrates grid drag-preview shadows and animations.
packages/​grid/​package.json Removes unused base-styles dependency.
packages/​grid/​CHANGELOG.md Records drag-preview shadow migration.
packages/​editor/​src/​components/​collaborators-presence/​avatar/​styles.scss Migrates avatar shadows.
packages/​editor/​src/​components/​collaborators-overlay/​style.module.scss Migrates collaborator cursor shadows.
packages/​editor/​src/​components/​collab-sidebar/​style.scss Migrates selected-note shadows.
packages/​edit-site/​src/​components/​layout/​style.scss Applies adaptive frame and content-area shadows.
packages/​edit-site/​CHANGELOG.md Documents adaptive site editor shadows.
packages/​boot/​src/​components/​root/​_layout.module.scss Resolves canvas shadow under the admin provider.
packages/​boot/​CHANGELOG.md Documents canvas shadow alignment.
packages/​block-editor/​src/​components/​writing-flow/​style.scss Migrates canvas stop-hint shadows.
packages/​block-editor/​src/​components/​inserter/​style.scss Migrates quick-inserter shadows.
packages/​block-editor/​src/​components/​block-draggable/​style.scss Migrates drag-chip shadows.
packages/​base-styles/​README.md Explains deprecation and provider-aware migration.
packages/​base-styles/​CHANGELOG.md Lists deprecated variables and replacements.
packages/​base-styles/​_variables.scss Marks variables deprecated without changing values.
package-lock.json Synchronizes removed development dependencies.

Review effort: Balanced

Comment thread packages/base-styles/CHANGELOG.md Resolved
@ciampo ciampo changed the title Base Styles: Deprecate $elevation-* and use the shadow tokens in Gutenberg Base Styles: Move Gutenberg from $elevation-* to the shadow tokens Dec 3, 2026
@ciampo
ciampo requested a review from mirka December 3, 2026 11:37
Comment thread tools/stylelint/config.js Outdated
const variable = size
? `$elevation-${ size }`
: `$shadow-${ alias }`;
return `Avoid using the \`${ variable }\` Sass variable. Use \`${ ELEVATION_VARIABLE_REPLACEMENTS[ size ?? alias ] }\` instead, and check that the surface floats over the background of the \`ThemeProvider\` it renders in.`;

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.

check that the surface floats over the background

the token is only right when a surface floats over its own provider's background. Someone has to check that for each surface, so a blanket alias isn't safe.

I was initially confused by these things (both what it means, and what I'm supposed to do about it) and had to ask my agent, who pointed me to the Shadows section of the theme package readme. Should we maybe link to that documentation in the message here? I guess it's not that important in this short-lived lint rule, but we'll definitely need to link it in the migration guidance that's coming up for external consumers.

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.

done

ciampo and others added 6 commits December 3, 2026 18:20
Keep the `$elevation-*` Sass variables at their static values, so code
outside Gutenberg doesn't move to the adaptive shadow without a check of
the background its surface floats over. Disallow them in Gutenberg with
Stylelint, and use the `--wpds-shadow-outer-*` tokens in their place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mark the variables deprecated in favor of the `--wpds-shadow-outer-*`
tokens, as the `$modal-width-*` variables were. Their values stay static.
Also flag `$shadow-popover` and `$shadow-modal`, add an edit-site
changelog entry, and show the token in the base-styles README example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match the site editor frame: the canvas uses `--wpds-shadow-outer-xs`,
resolved on `.surfaces` under the admin provider, because the canvas
renders inside the content provider but its shadow falls on the admin
background.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the changelog entry and the README and source notes that deprecate
the `$elevation-*` variables, and word the lint message like the radius
one. The public deprecation will land with the other design system
variables in a single release.
Say what the token assumes, and link the theme README section that
explains what to do when a surface doesn't float over its provider's
background.
@ciampo
ciampo force-pushed the update/elevation-variables-to-shadow-tokens branch from 54f56d6 to c7db021 Compare December 3, 2026 17:21
@ciampo
ciampo enabled auto-merge (squash) December 3, 2026 17:25
@ciampo
ciampo merged commit 66783e0 into trunk Dec 3, 2026
99 of 108 checks passed
@ciampo
ciampo deleted the update/elevation-variables-to-shadow-tokens branch December 3, 2026 17:45
@github-actions github-actions Bot added this to the Gutenberg 24.7 milestone Dec 3, 2026
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] Block editor /packages/block-editor [Package] Boot /packages/boot [Package] Edit Site /packages/edit-site [Package] Editor /packages/editor [Package] Grid /packages/grid [Package] Widget Dashboard /packages/widget-dashboard [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants