Skip to content

Components: update Button to use more wpds tokens - #79993

Open
simison wants to merge 8 commits into
trunkfrom
update/components-button-wpds-tokens
Open

simison wants to merge 8 commits into
trunkfrom
update/components-button-wpds-tokens

Conversation

@simison

@simison simison commented Jul 8, 2026 •

Copy link
Copy Markdown
Member

What?

Part of #76135

  • Migrate @wordpress/components Button baseline styles to WPDS tokens (typography, spacing, sizing, radius, and focus), while preserving existing component behaviour and legacy 36px default height.
  • Adds "With Icon" Storybook example for easier testing of that case specifically.
  • Updates "small" buttons to use same font size as UI Button (11px → 13px).

Doesn't migrate colour-related variables yet to keep testing easier/more focused. I have another follow-up which migrates colors: #79994

Earlier PRs on Button tokenisation:

Why?

Aligns Theming systems between @wordpress/components and @wordpress/ui.

How?

Testing Instructions

Run storybook: npm run storybook:dev and open http://localhost:50240/?path=/docs/components-button--docs

Verify Button variants in Storybook (default, primary, secondary, tertiary, link, small, compact, icon-only) all look and behave the same:

  • Resting
  • Hover
  • Focus
  • Focus hover
  • Active
  • Keyboard navigation

Testing Instructions for Keyboard

Screenshots or screencast

There should not be any visual difference between before/after:

Before

Screenshot 2026-07-08 at 12 46 27 Screenshot 2026-07-08 at 12 46 32 Screenshot 2026-07-14 at 18 21 14

After

Screenshot 2026-07-08 at 12 47 30 Screenshot 2026-07-08 at 12 47 35 Screenshot 2026-07-14 at 18 20 56

Icon one specifically:

Before

Screenshot 2026-07-08 at 13 08 31

After

image

Use of AI Tools

yes

@simison
simison requested review from a team and ajitbohra as code owners July 8, 2026 10:12
@simison simison added [Package] Components /packages/components [Feature] Component System WordPress component system Design System Issues related to the system of combining components according to best practices. labels Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Components, [Feature] Component System, Design System.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

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: simison <simison@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Comment on lines +12 to +13
// Legacy default height (36px) has no exact WPDS size token match.
--wp-components-button-height: 36px;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there's an alternative solution 🤔

@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Size Change: +435 B (+0.01%)

Total Size: 7.75 MB

📦 View Changed
Filename Size Change
build/styles/components/style-rtl.css 18.2 kB +112 B (+0.62%)
build/styles/components/style-rtl.min.css 15.1 kB +103 B (+0.69%)
build/styles/components/style.css 18.2 kB +115 B (+0.63%)
build/styles/components/style.min.css 15.1 kB +105 B (+0.7%)

compressed-size-action

@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Flaky tests detected in b87b609.
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.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29116506316
📝 Reported issues:

@simison

This comment was marked as outdated.

@ciampo ciampo 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.

I'm torn on whether we should continue to use the SASS variables or switch to WPDS tokens directly. if the goal is true @wordpress/ui alignment, we should migrate Button internals toward WPDS tokens directly. If the goal is legacy compatibility, keep component aliases or use local Button variables that bridge both, eg

--wp-components-button-background-color: var(
  --wp-components-color-accent,
  var(--wpds-color-background-interactive-brand-strong)
);

That gives a migration path without dropping existing customization hooks too abruptly.

Re. background: transparent, I guess that we should generally map to WPDS weak background tokens (instead of raw transparent) when they represent a button tone/variant.

We should also be careful when replacing background: none with a color token. background: none resets images too, which matters for busy/loading styles.

Here's a potential mapping
components primary
-> ui brand solid
bg: --wpds-color-background-interactive-brand-strong
bg active: --wpds-color-background-interactive-brand-strong-active
fg: --wpds-color-foreground-interactive-brand-strong

components secondary
-> ui brand outline
bg: --wpds-color-background-interactive-brand-weak        // #0000
bg active: --wpds-color-background-interactive-brand-weak-active
bg disabled: --wpds-color-background-interactive-brand-weak-disabled
border: --wpds-color-stroke-interactive-brand
fg: --wpds-color-foreground-interactive-brand

components tertiary
-> ui brand minimal
bg: --wpds-color-background-interactive-brand-weak        // #0000
bg active: --wpds-color-background-interactive-brand-weak-active
bg disabled: --wpds-color-background-interactive-brand-weak-disabled
fg: --wpds-color-foreground-interactive-brand

destructive secondary/tertiary
-> error outline/minimal equivalent
bg: --wpds-color-background-interactive-error-weak        // #0000
bg active: --wpds-color-background-interactive-error-weak-active
fg: --wpds-color-foreground-interactive-error
border: --wpds-color-stroke-interactive-error for outline-ish secondary

This is a change with a potential large visual impact, probably better to land it after the next Gutenberg release (which means this change will be included in WP 7.2, giving us ample time to test and make adjustments if needed)

Also cc @t-hamano as some the folks with the keenest eye on Button.

Comment on lines +71 to +73
// TODO: Prepare for theming (https://github.com/WordPress/gutenberg/pull/45466/files#r1030872724)
color: rgba($white, 0.4);
color: var(--wpds-color-foreground-interactive-brand-strong-disabled);

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.

This is a potentially substantial difference. More in general, would you mind updating a full matrix of the button variants, like done in #78646 ?

We have a specific Storybook example used for ad-hoc e2e viz reg that you can visit by running npm run storybook:e2e:dev

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tip about strokybook:e2e! Didn't know we had more examples to test with there.

I'm assuming some visual changes are ok considering what we just did with Notice.

Primary+disabled button:

Components Button in PR:
image

Components Button in trunk (looks better):
image

UI Button:
image

So I think we should change the background and text colour in tandem, at least for the disabled state, to avoid some kind of mixed style between the two that doesn't look that great.

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.

Yes, although I believe this warrants a broader conversation (to make sure we potentially address button styles on the php side) and the blessing of @WordPress/gutenberg-design

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.

Catching up. What needs a decision here? Is it the disabled state? If yes then I agree trunk looks better, gray on blue is barely legible (even though it doesn't have to be on a disabled button).

Noting that there was a previous attempt to move disabled buttons to look substantially less prominent in #70674, which was reverted specifically because we wanted to move towards a more considered token-based system. In that range, does this move us in the right direction? If it's mostly the disabled states, let me know and I'll test more in-depth those styles.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasmussen, in the UI-Button disabled state looks like this:

image

Can we make the components-Button look the same, or is it better to keep it as-is today (image below) and migrate to the new disabled style by swapping out components around Gutenberg one-by-one?

image

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.

Thanks for the clarity. I feel like this is moving in the right direction, on all counts, and is a good argument for why we made the origiginal change. It's exactly what we said we'd do: do it systematically, with tokens. Kudos.

Can we make the components-Button look the same, or is it better to keep it as-is today (image below) and migrate to the new disabled style by swapping out components around Gutenberg one-by-one?

That's a good question. In principle that would be ideal since they are meant to look the same. But perhaps it's okay for this to be a slow transition with the old still keeping the legacy behavior? How do you feel about it?

@ciampo ciampo Jul 13, 2026 •

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.

We did mention that, ideally, we would minimize the visual difference between @wordpress/components and @wordpress/ui componentry to ensure a better transition.

IMO, we should prioritize refactoring the styles in @wordpress/components to follow the new look from @wordpress/ui, since it will allow us to mix-and-match the two components (legacy and new version) without too many inconsistencies as we progressively refactor the repo (and as third party devs may continue to use the legacy version)

@simison
simison force-pushed the update/components-button-wpds-tokens branch from f9a939d to b87b609 Compare July 10, 2026 18:59
@simison

simison commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

I updated this PR to touch only font size, border width, spacing and things like that; I'm moving all the colours-related token swapping to happen at once in the follow-up PR #79994

I'll update PR description with screenshots.

Comment thread packages/components/CHANGELOG.md Outdated
Comment thread packages/components/src/button/style.scss
@simison
simison force-pushed the update/components-button-wpds-tokens branch from e8becb6 to e5a84a5 Compare July 15, 2026 07:28
Comment on lines 296 to 297
// 22px has no exact WPDS line-height token match (sm is 20px, md is 24px).
line-height: 22px;

@simison simison Jul 15, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI uses --wpds-typography-line-height-sm (20px) for all sizes, including small.

UI small = 24px tall, 13px font (font-size-md), 20px line-height, 0 vertical padding.

Components small = 24px tall, 11px font (font-size-xs), 22px line-height, 0 vertical padding.

Both end up 24px tall.

@simison simison Jul 15, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...separate question if we should align the font sizes for the small variant. Could be a good follow-up or done already here.

Default and compact use already the same font size.

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.

Outer size matches, although typography, internal spacing and "growth" behaviour are different.

I feel like the line height shouldn't be what guarantees the minimum clickable areas (24px), and therefore I prefer the wordpress/ui approach that uses min-height. Moreover, I believe that changing line-height here won't change the clickable box.

Still, I believe we could align font-size and line height here (ie. use font-size-md and line-height-sm) , I guess we could do it in this PR?

We will need to update the matrix screenshots, since small buttons will grow wider (not taller)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, I believe we could align font-size and line height here (ie. use font-size-md and line-height-sm) , I guess we could do it in this PR?

Let's do it. 👍 It's unavoidable anyway if we want to be able to mix components and have things look consistent.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

We will need to update the matrix screenshots, since small buttons will grow wider (not taller)

There was no small (nor compact) variants in the e2e matrix.

I added them locally and here's comparison, but snapshots wouldn't need updating:

Before
Screenshot 2026-07-16 at 15 55 45

After
Screenshot 2026-07-16 at 15 55 28

UI Button matrix with same additions:

image

@simison simison Jul 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm link button in small format now inherits wrong padding, need to fix that.

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.

Sounds good! Let me know once you've fixed that and I'll take another look

@simison simison Jul 17, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super pretty but simply avoiding resetting the padding to 0: dc954ec

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.

Hmm, I can see some regressions with small link buttons height:

Excluding .is-link from both height and padding fixes the horizontal padding, but it makes the small link target depend on its content. With the current cascade, a text-only small link is 20px tall, an icon-only one is 24px, and an icon-and-text one is 36px because the later .has-icon rule restores 6px block padding around the 24px icon. Trunk kept all three at 24px. Could we guarantee the 24px small control height for every variant and special-case only the link padding? The small link-and-icon case also needs to avoid reacquiring that later block padding.

@simison
simison force-pushed the update/components-button-wpds-tokens branch from 5844afe to 5872476 Compare July 15, 2026 08:11
@simison

simison commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

This is a change with a potential large visual impact, probably better to land it after the next Gutenberg release (which means this change will be included in WP 7.2, giving us ample time to test and make adjustments if needed)

@ciampo, agreed on this — which exact GB version is safe for Button changes?

@ciampo

ciampo commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This is a change with a potential large visual impact, probably better to land it after the next Gutenberg release (which means this change will be included in WP 7.2, giving us ample time to test and make adjustments if needed)

@ciampo, agreed on this — which exact GB version is safe for Button changes?

Probably 23.7? (@t-hamano can confirm)

@t-hamano

Copy link
Copy Markdown
Contributor

This is a change with a potential large visual impact, probably better to land it after the next Gutenberg release (which means this change will be included in WP 7.2, giving us ample time to test and make adjustments if needed)

@ciampo, agreed on this — which exact GB version is safe for Button changes?

Probably 23.7? (@t-hamano can confirm)

This PR will not be backported to WP 7.1, correct? If so, there is nothing to do. Merging this PR now will release it as part of GB 23.7.

Comment thread packages/components/src/button/style.scss
Comment on lines 296 to 297
// 22px has no exact WPDS line-height token match (sm is 20px, md is 24px).
line-height: 22px;

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.

Outer size matches, although typography, internal spacing and "growth" behaviour are different.

I feel like the line height shouldn't be what guarantees the minimum clickable areas (24px), and therefore I prefer the wordpress/ui approach that uses min-height. Moreover, I believe that changing line-height here won't change the clickable box.

Still, I believe we could align font-size and line height here (ie. use font-size-md and line-height-sm) , I guess we could do it in this PR?

We will need to update the matrix screenshots, since small buttons will grow wider (not taller)

@simison
simison force-pushed the update/components-button-wpds-tokens branch 3 times, most recently from 037c139 to dc954ec Compare July 17, 2026 16:46
@ciampo

ciampo commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Now that 7.1 shipped, should we resume work and aim to ship this soon into the 7.2 dev cycle?

Noting that, in the meantime, we've unified focus rings already

This branch has not been deployed

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

Labels

Design System Issues related to the system of combining components according to best practices. [Feature] Component System WordPress component system [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants