Skip to content

Button: Use semantic colors for ordinary and destructive states - #86683

Merged
ciampo merged 12 commits into
trunkfrom
codex/button-semantic-colors
Nov 12, 2026
Merged

ciampo merged 12 commits into
trunkfrom
codex/button-semantic-colors

Conversation

@ciampo

@ciampo ciampo commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #86681. Second slice of #85073; pressed Button/Toolbar/header colors follow separately.

What?

Map ordinary and destructive Button colors to WPDS foreground, background and stroke tokens.

Why?

A shared accent color cannot represent readable text, solid fills and borders across dark and custom themes.

How?

Share tone-dependent foreground, background and stroke roles through private variables so ordinary and destructive variants can reuse the existing declarations. Use WPDS tokens directly for fixed color roles. Remove ButtonGroup’s fixed foreground override and use a semantic outline token. Preserve busy stripes by updating the background color without clearing the gradient. Keep pressed foregrounds and fills together during keyboard activation, and remove duplicate destructive hover rules.

Color customization changes: With WPDS tokens loaded, these colors follow ThemeProvider instead of legacy --wp-components-color-* or admin color overrides. Generated fallbacks still supply colors when tokens are absent.

Testing Instructions

  1. Run npm run storybook:e2e:dev and open Button → Variant States.
  2. Compare primary, secondary, tertiary, default and link buttons in light, dark and a custom orange theme. Check ordinary, destructive, disabled and busy combinations.
  3. Hover the buttons. Busy stripes and readable labels should remain visible.
  4. In the post editor, open the Block Inserter and toggle Bold in a paragraph. The overridden header and block-toolbar controls should keep their existing appearance. Pressed-state token alignment is a separate follow-up.

Testing Instructions for Keyboard

Tab to ordinary and destructive controls, move the pointer away, and hold Space. Labels should remain readable. Repeat with busy controls and check that both stripes remain visible. For pressed default, secondary, tertiary and link Buttons, move the pointer away and hold Space. The pressed foreground and fill should stay paired.

Screenshots or screencast

Focused before/after comparisons

Before: trunk 895d31421abe. After: PR head 03bff48884a. Each pair uses the same production Button markup and ThemeProvider settings, with Button and ButtonGroup styles compiled from the indicated revision through the production token-fallback plugin. Captured at 480 CSS pixels wide, 2× scale and reduced motion. Hover and Space activation use real browser input. These are isolated component fixtures.

Custom orange foregrounds

The primary fill stays orange. Secondary, tertiary and link labels use a darker foreground, and the secondary border uses its stroke color.

Before After
Before: Custom orange foregrounds After: Custom orange foregrounds

Destructive colors in a dark theme

Default, secondary, tertiary and link destructive buttons use the theme's lighter error foreground and border instead of fixed red.

Before After
Before: Destructive colors in a dark theme After: Destructive colors in a dark theme

Busy primary button on hover

Hovering a busy primary button keeps both stripes visible instead of clearing the gradient.

Before After
Before: Busy primary button on hover After: Busy primary button on hover

Busy colors in a dark theme

Default, ordinary secondary and destructive secondary busy buttons use theme-aware stripe and label colors instead of light gray stripes.

Before After
Before: Busy colors in a dark theme After: Busy colors in a dark theme

Default buttons in a dark ButtonGroup

Grouped default buttons inherit their foreground and use a theme-aware outline. The previous dark text and outline blend into this dark background.

Before After
Before: Default buttons in a dark ButtonGroup After: Default buttons in a dark ButtonGroup

Pressed destructive button during Space activation

A default button with isDestructive and isPressed keeps its light foreground and dark pressed fill while Space is held. Before, the active styles replace them with red text on gray.

Before After
Before: Pressed destructive button during Space activation After: Pressed destructive button during Space activation
Complete color-state comparisons

Each matrix renders all five variants with every combination of pressed, destructive, busy, and enabled/native-disabled/focusable-disabled props. The local fixture uses production Button and its compiled package stylesheet. Hover, focus and active matrices use browser-forced CSS states to expose the full cascade; real Space activation and editor controls were checked separately. Disabled controls forced active are CSS inspection cases, not claims that they can be activated. The one-off fixture and checks are not part of this PR.

Before: c4aff0361d5. After: this branch. Matching 1180 × 1450 viewport and reduced motion.

Theme / CSS state Before After
light, rest Before: light, rest After: light, rest
light, hover Before: light, hover After: light, hover
light, focus Before: light, focus After: light, focus
light, active Before: light, active After: light, active
dark, rest Before: dark, rest After: dark, rest
dark, hover Before: dark, hover After: dark, hover
dark, focus Before: dark, focus After: dark, focus
dark, active Before: dark, active After: dark, active
orange, rest Before: orange, rest After: orange, rest
orange, hover Before: orange, hover After: orange, hover
orange, focus Before: orange, focus After: orange, focus
orange, active Before: orange, active After: orange, active
Real editor: header and block toolbar overrides

The isolated WordPress editor runs this checkout. The comparison loads each revision’s production components stylesheet, with the same paragraph, active Bold control and open Block Inserter. The surrounding editor code is unchanged by this PR.

Before After
Editor before Editor after
ButtonGroup: removed foreground override

These dedicated comparisons use the same themes, prop combinations and CSS interaction states as the individual Button matrices. ButtonGroup now inherits each Button’s foreground. Its outline remains because it defines grouped buttons that have no variant border.

Theme / CSS state Before After
light, rest Grouped buttons before: light, rest Grouped buttons after: light, rest
light, hover Grouped buttons before: light, hover Grouped buttons after: light, hover
light, focus Grouped buttons before: light, focus Grouped buttons after: light, focus
light, active Grouped buttons before: light, active Grouped buttons after: light, active
dark, rest Grouped buttons before: dark, rest Grouped buttons after: dark, rest
dark, hover Grouped buttons before: dark, hover Grouped buttons after: dark, hover
dark, focus Grouped buttons before: dark, focus Grouped buttons after: dark, focus
dark, active Grouped buttons before: dark, active Grouped buttons after: dark, active
orange, rest Grouped buttons before: orange, rest Grouped buttons after: orange, rest
orange, hover Grouped buttons before: orange, hover Grouped buttons after: orange, hover
orange, focus Grouped buttons before: orange, focus Grouped buttons after: orange, focus
orange, active Grouped buttons before: orange, active Grouped buttons after: orange, active
Earlier PR iteration: pressed destructive default Button

Hold Space on the pressed destructive default Button with the pointer away. Before is the previous PR head 89a4346000f; after is this branch. The foreground now stays paired with the pressed fill. The same guards protect pressed secondary and tertiary weak fills.

Before After
Pressed destructive default while holding Space, before Pressed destructive default while holding Space, after

Use of AI Tools

Implemented with Codex, including independent local agent review and one-off browser checks. No tests were added.

@github-actions github-actions Bot added the [Package] Components /packages/components label Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 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: +1.05 kB (+0.01%)

Total Size: 8.64 MB

📦 View Changed
Filename Size Change
build/styles/components/style-rtl.css 18.1 kB +231 B (+1.29%)
build/styles/components/style-rtl.min.css 15.2 kB +295 B (+1.98%)
build/styles/components/style.css 18.1 kB +229 B (+1.28%)
build/styles/components/style.min.css 15.2 kB +297 B (+1.99%)

7477255 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric f355bd8 trunk % Change
timeToFirstByte 57.75 ms +14.03% -8.05% 56.95 ms +11.76% -8.43% 1.4%
largestContentfulPaint 90 ms +17.78% -6.67% 90 ms +13.33% -8.89% 0%
lcpMinusTtfb 31.8 ms +18.08% -13.99% 32.65 ms +14.4% -17.61% -2.6%
wpBeforeTemplate 28.25 ms +12.11% -3.4% 28.74 ms +12.98% -7.93% -1.7%
wpTemplate 24.55 ms +14.75% -12.46% 23.63 ms +24.21% -11.89% 3.89%
wpTotal 53.04 ms +15.93% -6.62% 52.85 ms +12.87% -8.78% 0.36%
wpMemoryUsage 7.72 MB +0% -0% 7.69 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric f355bd8 trunk % Change
timeToFirstByte 44.55 ms +9.2% -5.61% 46.15 ms +7.37% -6.28% -3.47%
largestContentfulPaint 80 ms +5% -7.5% 82 ms +4.88% -7.32% -2.44%
lcpMinusTtfb 34.8 ms +5.89% -5.89% 33.5 ms +13.13% -7.16% 3.88%
wpBeforeTemplate 23.56 ms +8.23% -6.66% 23.63 ms +7.96% -5.37% -0.3%
wpTemplate 17.97 ms +7.18% -10.35% 18.41 ms +9.45% -6.57% -2.39%
wpTotal 41.29 ms +9.18% -6.15% 42.89 ms +6.09% -6.92% -3.73%
wpMemoryUsage 6.41 MB +0% -0% 6.38 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric f355bd8 trunk % Change
mediaProcessingJpeg 352.88 ms +0.76% -1.97% 353.62 ms +6.22% -1.46% -0.21%
mediaProcessingAvif 5165.24 ms +0.24% -0.3% 5145 ms +1.16% -0.57% 0.39%
mediaProcessingJpegToAvif 3633.6 ms +0.3% -0.79% 3575.29 ms +1.23% -0.3% 1.63%

media-upload

Metric f355bd8 trunk % Change
jpegUploadProcessing 1561.47 ms +31.08% -2.97% 1501.17 ms +1.8% -1.51% 4.02%
pngUploadProcessing 291.69 ms +7.84% -8.63% 293 ms +3.56% -18.27% -0.45%
largeJpegUploadProcessing 1519.34 ms +1.92% -1.48% 1520 ms +1.04% -2.11% -0.04%
multipleImageUploadProcessing 1799.43 ms +6.85% -2.83% 1737.23 ms +7.96% -1.53% 3.58%

post-editor

Metric f355bd8 trunk % Change
serverResponse 478.93 ms +2.74% -0.48% 489.11 ms +1.91% -8.66% -2.08%
firstPaint 418.48 ms +5.95% -6.97% 428.86 ms +2.62% -7.34% -2.42%
domContentLoaded 802.23 ms +1.35% -0.96% 805.73 ms +2.34% -2.01% -0.43%
loaded 803.34 ms +1.34% -1% 806.84 ms +2.34% -2.01% -0.43%
firstContentfulPaint 461.88 ms +2.24% -3.12% 456.95 ms +5.17% -1.98% 1.08%
firstBlock 2168.27 ms +5.51% -1.2% 2178.59 ms +1.97% -1.26% -0.47%
type 17.93 ms +7.03% -16.17% 17.12 ms +3.39% -10.57% 4.73%
typeWithoutInspector 16.42 ms +4.08% -10.23% 16.55 ms +8.52% -4.29% -0.79%
typeWithTopToolbar 23.19 ms +2.5% -13.63% 22.76 ms +8.44% -5.1% 1.89%
typeContainer 8.42 ms +9.74% -14.73% 8.32 ms +9.62% -10.94% 1.2%
focus 120.74 ms +6.99% -4.2% 117.17 ms +4.37% -0.64% 3.05%
firstFocus 276.65 ms +0% -0% 255.65 ms +0% -0% 8.21%
selectAll 396.86 ms +6.01% -2.24% 401.96 ms +1.69% -0.88% -1.27%
undo 28.65 ms +6.63% -4.19% 27.64 ms +6.73% -4.02% 3.65%
listViewOpen 82.6 ms +3.5% -9.38% 73.97 ms +15.53% -7.33% 11.67%
inserterOpen 41.84 ms +11.81% -6.86% 40.02 ms +7.37% -3.67% 4.55%
inserterHover 10.99 ms +8.74% -5.55% 11.56 ms +6.75% -14.1% -4.93%
inserterSearch 7.31 ms +7.52% -3.15% 7.93 ms +4.04% -4.79% -7.82%
loadPatterns 653.81 ms +7.23% -8.97% 639.43 ms +4.28% -2.8% 2.25%
wpTotal 469.28 ms +2.55% -0.5% 478.53 ms +1.88% -8.92% -1.93%
wpMemoryUsage 14.78 MB +0% -0% 14.74 MB +0% -0% 0.24%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric f355bd8 trunk % Change
serverResponse 409.12 ms +1.23% -1% 411.98 ms +0.61% -0.93% -0.69%
firstPaint 405.38 ms +15% -2.41% 428.16 ms +10.56% -9.24% -5.32%
domContentLoaded 837.55 ms +3.33% -1.28% 841.25 ms +1.88% -1.21% -0.44%
loaded 838.58 ms +3.32% -1.27% 842.33 ms +1.9% -1.23% -0.45%
firstContentfulPaint 465.16 ms +5.2% -1.53% 471.38 ms +4.53% -3.07% -1.32%
firstBlock 2461.15 ms +1.75% -1.01% 2504.72 ms +0.34% -0.57% -1.74%
type 17.59 ms +8.24% -9.66% 17.48 ms +5.55% -7.95% 0.63%
navigate 127.54 ms +2.48% -3.69% 118.48 ms +7.28% -3.55% 7.65%
loadPatterns 1435.81 ms +4.36% -7.33% 1365.03 ms +5.59% -8.09% 5.19%
loadPages 941.85 ms +1.66% -1.65% 927.36 ms +1.3% -0.29% 1.56%
wpTotal 399.69 ms +1.15% -0.92% 402.77 ms +0.55% -0.96% -0.76%
wpMemoryUsage 12.79 MB +0% -0% 12.76 MB +0% -0% 0.24%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

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

Undo restores the post selection when another synced entity is loaded in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 2,
+   "offset": 2,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5

allows blocks to be added on mobile viewports in /test/e2e/specs/widgets/editing-widgets.spec.js, passed after 1 failed attempt.

keeps the default tab on the moved tab in /test/e2e/specs/editor/blocks/tabs.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

Expected: 0
Received: 1

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/tabs.spec.js:359:60
should apply a named font size using the font size buttons in /test/e2e/specs/editor/various/font-size-picker.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:paragraph {"fontSize":"large"} -->
+ <!-- wp:paragraph {"fontSize":"medium"} -->
- <p class="has-large-font-size">Paragraph to be made "large"</p>
+ <p class="has-medium-font-size">Paragraph to be made "large"</p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/font-size-picker.spec.js:153:6
should reset a named font size using the tools panel menu in /test/e2e/specs/editor/various/font-size-picker.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:paragraph {"fontSize":"medium"} -->
+ <!-- wp:paragraph {"fontSize":"small"} -->
- <p class="has-medium-font-size">Paragraph with font size reset using tools panel menu</p>
+ <p class="has-small-font-size">Paragraph with font size reset using tools panel menu</p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/font-size-picker.spec.js:178:6
should restore an older revision in /test/e2e/specs/editor/various/revisions.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: 'Editor settings' }).getByRole('button', { name: 'Open revisions screen: 2 revisions' })

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/revisions.spec.js:67:5

7477255 Run

@ciampo ciampo added the [Type] Enhancement A suggestion for improvement. label Nov 11, 2026
@ciampo ciampo self-assigned this Nov 11, 2026
@ciampo
ciampo marked this pull request as ready for review November 11, 2026 18:17
@ciampo
ciampo requested a review from a team as a code owner November 11, 2026 18:17
@ciampo
ciampo requested review from a team and a balanced review from Copilot November 11, 2026 18:18

This comment was marked as resolved.

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

The review identifies no active issues with the Button and ButtonGroup semantic-color migration.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@ciampo
ciampo force-pushed the codex/button-disabled-tokens branch from c4aff03 to fb5d688 Compare November 12, 2026 08:37
Base automatically changed from codex/button-disabled-tokens to trunk November 12, 2026 09:23
@ciampo
ciampo force-pushed the codex/button-semantic-colors branch from 08b7607 to 03bff48 Compare November 12, 2026 09:51
Comment thread packages/components/CHANGELOG.md Resolved
@ciampo
ciampo force-pushed the codex/button-semantic-colors branch from 03bff48 to 7477255 Compare November 12, 2026 17:12
@ciampo
ciampo enabled auto-merge (squash) November 12, 2026 17:15
@ciampo
ciampo merged commit 2c91b15 into trunk Nov 12, 2026
83 checks passed
@ciampo
ciampo deleted the codex/button-semantic-colors branch November 12, 2026 17:42
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 12, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
…Press#86683)

* Button: Map ordinary and destructive states to WPDS colors

* Button: Preserve pressed colors and remove the grouped foreground override

* Button: Link semantic color changes to their PR

* Button: Use interactive neutral foreground roles

* Button: Share disabled strong colors by tone

* Button: Apply colors through consistent state variables

* Button: Remove color-state normalization

* Button: Preserve pressed colors during keyboard activation

* Button: Keep the destructive active foreground

* Button: Keep pressed foreground and fill guards together

* Button: Preserve disabled brand colors after rebase

* Button: Omit deprecated ButtonGroup from the changelog

---

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@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 [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants