Skip to content

Allow tooltip color customization#79612

Draft
shaunandrews wants to merge 1 commit into
trunkfrom
add-tooltip-color-css-vars
Draft

Allow tooltip color customization#79612
shaunandrews wants to merge 1 commit into
trunkfrom
add-tooltip-color-css-vars

Conversation

@shaunandrews

Copy link
Copy Markdown
Contributor

What?

See Automattic/studio#3981.

Adds tooltip popup color customization variables:

  • --wp-ui-tooltip-background-color
  • --wp-ui-tooltip-color

The default tooltip appearance is unchanged because both variables fall back to the existing WPDS tooltip surface and foreground tokens. The PR also adds a Storybook story showing per-instance color customization through Tooltip.Portal.

Why?

Consumers can already customize tooltip stacking with --wp-ui-tooltip-z-index, but tooltip colors are currently fixed inside the component stylesheet. That makes app-level theme adjustments hard when a product needs a different tooltip treatment in a specific theme, such as Studio's dark mode.

Exposing semantic tooltip CSS variables gives consumers a stable API instead of pushing them toward generated CSS module selectors or wrapper-specific workarounds.

How?

The tooltip stylesheet now reads the popup background and text colors from CSS custom properties before falling back to the current design-system tokens.

The new Storybook example mirrors the existing custom z-index story: consumers can set the variables globally on :root/body, or per tooltip by passing a styled Tooltip.Portal to Tooltip.Popup.

Testing Instructions

  1. Open the Tooltip Storybook examples.
  2. Open "With Custom Colors".
  3. Hover or focus the trigger.
  4. Confirm the tooltip popup uses the custom background and text colors.
  5. Open the default Tooltip story and confirm the default tooltip colors are unchanged.

Validation run:

  • git diff --check

Full Gutenberg lint/test commands were not run in this temporary sparse checkout because dependencies were not installed.

Testing Instructions for Keyboard

  1. Open the Tooltip "With Custom Colors" story.
  2. Use keyboard navigation to focus the trigger.
  3. Confirm the tooltip popup appears with the custom background and text colors.

Screenshots or screencast

Not captured.

Use of AI Tools

Codex helped trace the downstream Studio use case and draft this small source change. I reviewed the resulting diff before opening the PR.

@github-actions github-actions Bot added the [Package] UI /packages/ui label Jun 27, 2026
@github-actions

Copy link
Copy Markdown

Size Change: +220 B (0%)

Total Size: 7.52 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 51.1 kB +36 B (+0.07%)
build/modules/content-types/index.min.js 160 kB +38 B (+0.02%)
build/scripts/block-directory/index.min.js 44 kB +21 B (+0.05%)
build/scripts/block-editor/index.min.js 383 kB +22 B (+0.01%)
build/scripts/edit-post/index.min.js 52.3 kB +33 B (+0.06%)
build/scripts/edit-site/index.min.js 298 kB +33 B (+0.01%)
build/scripts/editor/index.min.js 487 kB +16 B (0%)
build/scripts/media-utils/index.min.js 115 kB +21 B (+0.02%)

compressed-size-action

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

Labels

[Package] UI /packages/ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant