Skip to content

Tooltip: Invert the theme's neutral tokens instead of nesting a dark ThemeProvider - #87817

Merged
ciampo merged 16 commits into
trunkfrom
t3/tooltip-theme-token-followup
Dec 2, 2026
Merged

ciampo merged 16 commits into
trunkfrom
t3/tooltip-theme-token-followup

Conversation

@ciampo

@ciampo ciampo commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What?

Follow-up to #87287 (follow-up 1a).

Tooltip.Popup in @wordpress/ui no longer wraps its content in a ThemeProvider with a fixed #1e1e1e background. It swaps two neutral tokens instead: --wpds-color-foreground-content-neutral for the background and --wpds-color-background-surface-neutral for the text. The @wordpress/components Tooltip uses the same two tokens in place of its hard-coded $gray-900 and $gray-100.

Why?

The nested provider was added in #74625, because no token existed for an always-dark surface. It makes the tooltip ignore the page theme. It also forced #87287 to resolve the shadow on the positioner (--_wp-ui-tooltip-shadow), so that the tooltip shadow follows the page and not the tooltip's own dark seed. Without the nested provider, the popup reads the page's tokens directly, and the workaround goes away.

This is the best short-term compromise we found to remove the ThemeProvider hack. It does not commit to new WPDS tokens, and it keeps most of the current appearance. The main visible change is in dark themes, where tooltips now turn light. Dark themes are not widely used in WordPress today. The long-term design of tooltips and snackbars in dark themes is tracked in #87834.

How?

  • Colors: the swapped tokens are a temporary hack until Design System: Decide how Tooltip, Snackbar and other "perma dark" overlays should look like in dark themes #87834 is decided, and the comments in both stylesheets link to it. The design system has no inverted-surface tokens yet, and the only inverted tokens that exist (*-interactive-neutral-strong) are meant for controls.
  • Light themes: the background changes from #252525 to #1e1e1e, and the text from #f0f0f0 to #fcfcfc, the default neutral surface.
  • Dark themes: the tooltip uses the theme's foreground color as its background, for example #f0f0f0 with #1e1e1e text on the dark Storybook theme.
  • Shadow: the popup resolves --wpds-shadow-outer-sm from the page's provider, so the positioner no longer needs --_wp-ui-tooltip-shadow.
  • wp-admin: both tooltips render through a portal, so they read the root provider's tokens. The root provider is light in the site editor and the other admin screens, so tooltips stay dark there, also when opened from the dark site editor sidebar.
  • Popup content: content inside Tooltip.Popup that uses --wpds-color-* tokens used to get the values of the nested dark theme. It now gets the page theme's values. No popup content in the repository uses these tokens.
  • Theme compatibility fixture: the checkout @wordpress/ui bundle no longer mounts ThemeProvider, so tools/validation/fixtures/theme-compatibility/README.md now scopes the fallback checks to the published bundle.
  • Unrelated changelog fix: the @wordpress/components changelog entry for Components: Use WPDS stroke tokens on raised surfaces #87840 moves from the 45.1.0 section to Unreleased.
Why not use the always-dark ("perma-dark") ramp colors?

The background ramp generates an always-dark fill, bgFillDark, and its text color, fgFillDark. Using them would keep tooltips dark in dark themes. But primitive ramp colors are not emitted as CSS custom properties. Only semantic tokens are. No semantic token aliases bgFillDark, and fgFillDark is reachable only through --wpds-color-background-thumb-neutral (the switch knob). Using the perma-dark colors would need a new token, which is what this PR avoids.

Also, bgFillDark is #1e1e1e on light seeds but #000 on dark seeds, so even that token would change how tooltips look in dark themes.

Follow-ups

Testing Instructions

  1. Run npm run storybook:dev.
  2. Open Components > @wordpress-ui > Tooltip > Default and hover the trigger. The tooltip should be dark, with light text.
  3. In the toolbar, switch the design system color theme to Dark. The tooltip should be light, with dark text.
  4. Repeat steps 2 and 3 in Components > @wordpress-components > Deprecated > Tooltip > Default.
  5. Open the site editor and hover the WordPress logo in the dark sidebar. The "Go to the Dashboard" tooltip should still be dark.

Testing Instructions for Keyboard

No interaction changes. Focus a tooltip trigger with Tab. The tooltip should open with the colors described above.

Screenshots

Storybook design-system-components-tooltip--default, dark color theme:

Before After
Dark tooltip on the dark theme Light tooltip on the dark theme
Light theme, and the @wordpress/components Tooltip

@wordpress/ui Tooltip, light color theme:

Before After
@wordpress/ui tooltip before, light theme @wordpress/ui tooltip after, light theme

@wordpress/components Tooltip (components-tooltip--default), light color theme:

Before After
@wordpress/components tooltip before, light theme @wordpress/components tooltip after, light theme

@wordpress/components Tooltip, dark color theme:

Before After
@wordpress/components tooltip before, dark theme @wordpress/components tooltip after, dark theme

Use of AI Tools

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

🤖 Generated with Claude Code

@github-actions github-actions Bot added [Package] Components /packages/components [Package] UI /packages/ui 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: 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 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: -6.22 kB (-0.07%)

Total Size: 8.73 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 54.8 kB -334 B (-0.61%)
build/modules/core-fields/attachment.min.js 43.9 kB -306 B (-0.69%)
build/modules/core-fields/post_type_supports.min.js 87.6 kB -15 B (-0.02%)
build/modules/core-fields/wp_block.min.js 32.6 kB -347 B (-1.05%)
build/modules/core-fields/wp_template_part.min.js 39.2 kB -316 B (-0.8%)
build/scripts/block-directory/index.min.js 42.3 kB -308 B (-0.72%)
build/scripts/block-editor/index.min.js 562 kB -287 B (-0.05%)
build/scripts/block-library/index.min.js 431 kB -1.17 kB (-0.27%)
build/scripts/components/index.min.js 358 kB -373 B (-0.1%)
build/scripts/edit-post/index.min.js 45.1 kB -131 B (-0.29%)
build/scripts/edit-site/index.min.js 376 kB -685 B (-0.18%)
build/scripts/editor/index.min.js 575 kB -728 B (-0.13%)
build/scripts/media-utils/index.min.js 234 kB -923 B (-0.39%)
build/scripts/notices/index.min.js 47.6 kB -331 B (-0.69%)
build/styles/components/style-rtl.css 18.7 kB +7 B (+0.04%)
build/styles/components/style-rtl.min.css 15.8 kB +8 B (+0.05%)
build/styles/components/style.css 18.8 kB +7 B (+0.04%)
build/styles/components/style.min.css 15.8 kB +6 B (+0.04%)

4e57a07 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 2a159c2 trunk % Change
timeToFirstByte 58.4 ms +4.11% -3.51% 57.95 ms +6.3% -1.47% 0.78%
largestContentfulPaint 90 ms +6.67% -2.22% 90 ms +6.67% -2.22% 0%
lcpMinusTtfb 30.5 ms +20.49% -4.1% 30.4 ms +15.46% -4.93% 0.33%
wpBeforeTemplate 30.84 ms +5.22% -3.05% 30.84 ms +9.99% -1.69% 0%
wpTemplate 23.22 ms +2.33% -3.7% 23.08 ms +3.81% -2.69% 0.61%
wpTotal 54.41 ms +4.01% -3.36% 53.9 ms +6.36% -1.65% 0.95%
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 2a159c2 trunk % Change
timeToFirstByte 48.9 ms +4.91% -2.66% 47.75 ms +6.6% -1.68% 2.41%
largestContentfulPaint 84 ms +9.52% -0% 80 ms +5% -0% 5%
lcpMinusTtfb 36.05 ms +10.4% -4.44% 33.25 ms +4.51% -1.65% 8.42%
wpBeforeTemplate 28.47 ms +7.2% -5.06% 27.3 ms +7.18% -1.36% 4.29%
wpTemplate 17.2 ms +4.71% -4.88% 17.06 ms +3.28% -4.45% 0.82%
wpTotal 45.44 ms +4.01% -2.29% 44.47 ms +5.76% -1.24% 2.18%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 2a159c2 trunk % Change
mediaProcessingJpeg 404.55 ms +2.65% -2.06% 404.3 ms +2.49% -0.83% 0.06%
mediaProcessingAvif 6109.94 ms +0.24% -0.18% 6124.46 ms +0.17% -0.29% -0.24%
mediaProcessingJpegToAvif 4219.62 ms +0.12% -0.27% 4224.77 ms +0.78% -0.82% -0.12%

media-upload

Metric 2a159c2 trunk % Change
jpegUploadProcessing 1974.94 ms +2.95% -23.64% 1980.19 ms +0.94% -22.87% -0.27%
pngUploadProcessing 277.71 ms +3.91% -1.81% 277.61 ms +1.33% -2.74% 0.04%
largeJpegUploadProcessing 1522.53 ms +30.79% -1.5% 1962.12 ms +0.81% -22.53% -22.4%
multipleImageUploadProcessing 2116.86 ms +1.64% -0.96% 2128.11 ms +0.83% -2.49% -0.53%

post-editor

Metric 2a159c2 trunk % Change
serverResponse 275.23 ms +6.1% -7.8% 256.46 ms +6.02% -4.43% 7.32%
firstPaint 273.12 ms +17.37% -6.48% 283.3 ms +9.63% -10.04% -3.59%
domContentLoaded 571.46 ms +1.77% -1.8% 528.91 ms +3.75% -2.66% 8.04%
loaded 572.78 ms +1.77% -1.82% 530.02 ms +3.77% -2.66% 8.07%
firstContentfulPaint 320.38 ms +1.12% -1.84% 310.38 ms +2.4% -0.98% 3.22%
firstBlock 1548.55 ms +1.53% -2.05% 1413.84 ms +4.81% -2.04% 9.53%
type 14.81 ms +2.43% -15.46% 13.04 ms +7.75% -4.6% 13.57%
typeWithoutInspector 15.65 ms +10.35% -8.43% 13.36 ms +8.83% -8.38% 17.14%
typeWithTopToolbar 18.62 ms +9.51% -4.4% 17.65 ms +7.42% -2.61% 5.5%
typeContainer 6.51 ms +3.84% -6.14% 6.61 ms +8.77% -11.5% -1.51%
focus 68.56 ms +6.59% -4.22% 77.18 ms +3.93% -3.93% -11.17%
firstFocus 187.35 ms +0% -0% 196.74 ms +0% -0% -4.77%
selectAll 240.03 ms +2.35% -1.7% 260.57 ms +0.21% -1.68% -7.88%
undo 20.13 ms +7.8% -3.18% 22.66 ms +9.14% -2.38% -11.17%
listViewOpen 25.37 ms +5.95% -1.66% 27.39 ms +3.07% -5.4% -7.37%
inserterOpen 27.09 ms +8.16% -8.19% 28.48 ms +1.93% -6.11% -4.88%
inserterHover 8 ms +5.75% -4.37% 8.86 ms +7% -4.63% -9.71%
inserterSearch 6.56 ms +1.68% -4.12% 6.85 ms +3.65% -0.73% -4.23%
loadPatterns 439.36 ms +1.37% -3.4% 458.2 ms +2.89% -5.29% -4.11%
wpTotal 268.08 ms +6.2% -7.94% 249.79 ms +5.79% -4.6% 7.32%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 2a159c2 trunk % Change
serverResponse 472.4 ms +0.37% -8.2% 467.93 ms +0.68% -8.04% 0.96%
firstPaint 451.53 ms +6.77% -15.63% 411.12 ms +13.58% -12.8% 9.83%
domContentLoaded 851.33 ms +2.06% -2.31% 832.9 ms +1.2% -1.43% 2.21%
loaded 852.91 ms +2.04% -2.32% 834.56 ms +1.2% -1.45% 2.2%
firstContentfulPaint 467.07 ms +6.81% -4.26% 460.24 ms +2.37% -1.41% 1.48%
firstBlock 2621.74 ms +7.74% -1.04% 2637.2 ms +1.98% -1.38% -0.59%
type 18.89 ms +1.96% -14.24% 16.96 ms +7.25% -5.84% 11.38%
navigate 110.99 ms +2.05% -1.12% 115.88 ms +3.9% -0.42% -4.22%
loadPatterns 1576.52 ms +6.4% -7.31% 1687.14 ms +4.22% -3.57% -6.56%
loadPages 966.47 ms +1.81% -0.49% 974.81 ms +1.28% -1.44% -0.86%
wpTotal 462.74 ms +0.42% -8.34% 458.57 ms +0.66% -8.23% 0.91%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

4e57a07 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.

Submenu interactions on Safari (@WebKit) in /test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: 'Editor top bar' }).getByRole('button', { name: 'Save', exact: true })
    - locator resolved to <button type="button" aria-disabled="true" class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact">Save</button>
  - attempting click action
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
    - waiting 20ms
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
      - waiting 100ms
    15 × waiting for element to be visible, enabled and stable
       - element is not enabled
     - retrying click action
       - waiting 500ms

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:39:22)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:387:4

4e57a07 Run

Comment thread packages/ui/CHANGELOG.md Resolved
Comment thread packages/components/CHANGELOG.md Resolved
ciampo and others added 13 commits December 2, 2026 23:06
Drop the ThemeProvider that Tooltip.Popup rendered with a fixed #1e1e1e
background. Swap the neutral content tokens instead, so the tooltip
contrasts with the surrounding theme, and remove the
--_wp-ui-tooltip-shadow workaround on the positioner. Apply the same
tokens to the @wordpress/components Tooltip.

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>
…erences

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lity fixture

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bundle

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>
…dependency

No component mounts ThemeProvider since the Tooltip change, so the fallback
and its lock-unlock module have no runtime consumer. Tests import
ThemeProvider from @wordpress/theme directly. Keep @wordpress/ui in the
private APIs allowlist, because published versions still opt in.

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>
@ciampo
ciampo force-pushed the t3/tooltip-theme-token-followup branch from bfb887a to 4e57a07 Compare December 2, 2026 22:07
@ciampo
ciampo enabled auto-merge (squash) December 2, 2026 22:09
@ciampo
ciampo merged commit ffea9a2 into trunk Dec 2, 2026
87 of 88 checks passed
@ciampo
ciampo deleted the t3/tooltip-theme-token-followup branch December 2, 2026 22:28
@github-actions github-actions Bot added this to the Gutenberg 24.7 milestone Dec 2, 2026
ciampo added a commit that referenced this pull request Dec 3, 2026
The tests covered the swapped neutral tokens from #87817. The tooltip now uses the surface tokens like any other overlay, so they no longer test anything specific to it.
ciampo added a commit that referenced this pull request Dec 3, 2026
The tests covered the swapped neutral tokens from #87817. The tooltip now uses the surface tokens like any other overlay, so they no longer test anything specific to it.
ciampo added a commit that referenced this pull request Dec 3, 2026
* Tooltip, Snackbar: Follow the theme instead of staying dark

Implement option C from #87834. Tooltip (both packages), Snackbar, the
block drag chip, and the canvas stop hint now use the neutral surface,
text, and stroke tokens of the theme around them, like popovers, instead
of fixed dark colors or swapped tokens. Remove the patches that kept the
snackbar action text and upload spinner white.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Add changelog entries

Rewrite the unreleased Tooltip entries for the final behavior, and remove the
unreleased Snackbar and upload spinner fixes that no longer apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Block Editor: Keep the drag chip height with its new border

Include the border in the chip's height so the chip stays centered on the
pointer, and drop a radius the invalid overlay could not inherit.

* Site Editor: Use the content colors for every snackbar

Snackbars over the mobile sidebar took the admin color scheme, so they
turned dark or tinted while tooltips and menus over the same sidebar stay
light. Seed them with the content colors everywhere, like the extensible
site editor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* RangeControl, ResizableBox: Follow the theme in the value and size tooltips

The RangeControl value tooltip and the ResizableBox size tooltip were the
last dark tooltips. Give them the theme's surface, text, stroke, and
shadow, like Tooltip.

Also keep the drag chip's "cannot drop here" symbol in forced-colors
mode, which stripped the box-shadow and gradient that draw it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* RangeControl, ResizableBox: Use WPDS tokens for the tooltip colors

Reference the design system tokens directly, like Tooltip and Popover,
instead of the legacy `--wp-components-color-*` variables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* UI: Drop the forced-colors border override from Tooltip

Forced-colors mode already draws the stroke in a system color, as it does for Popover.

* UI: Drop the Tooltip theme tests

The tests covered the swapped neutral tokens from #87817. The tooltip now uses the surface tokens like any other overlay, so they no longer test anything specific to it.

---------

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

2 participants