Repository navigation
Button: Use semantic colors for ordinary and destructive states - #86683
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +1.05 kB (+0.01%) Total Size: 8.64 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome 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
|
c4aff03 to
fb5d688
Compare
08b7607 to
03bff48
Compare
03bff48 to
7477255
Compare
…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>

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
ThemeProviderinstead of legacy--wp-components-color-*or admin color overrides. Generated fallbacks still supply colors when tokens are absent.Testing Instructions
npm run storybook:e2e:devand open Button → Variant States.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 head03bff48884a. 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.
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.
Busy primary button on hover
Hovering a busy primary button keeps both stripes visible instead of clearing the gradient.
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.
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.
Pressed destructive button during Space activation
A default button with
isDestructiveandisPressedkeeps its light foreground and dark pressed fill while Space is held. Before, the active styles replace them with red text on gray.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.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.
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.
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.Use of AI Tools
Implemented with Codex, including independent local agent review and one-off browser checks. No tests were added.