Skip to content

Components: Add Button migration guide to @wordpress/ui Button - #87931

Open
aduth wants to merge 1 commit into
trunkfrom
add/button-migration-guide
Open

aduth wants to merge 1 commit into
trunkfrom
add/button-migration-guide

Conversation

@aduth

@aduth aduth commented Dec 3, 2026

Copy link
Copy Markdown
Member

What?

Adds a "Migration Guide" for migrating from @wordpress/component's Button to @wordpress/ui equivalents.

Addresses #76135 (comment)

Why?

In preparation for stabilizing @wordpress/ui's Button, having a migration guide will help consumers of the existing @wordpress/components Button adapt their code to use the new component.

Migration guides are mentioned as part of the process for replacing a legacy component. This follows precedent for several other component migration guides that already exist (example).

Since Button is one of the most commonly-used components, and the new Button component abstractions are significantly different than how they existed previously, it's particularly important that we provide clear guidance on how to adapt existing code to use the new components.

How?

This only adds the migration guide content. It doesn't change anything about either implementation's stability or recommendation. As there is no prior art for implementing a migration guide before a component's stabilization, the text includes a note that the new components "are not yet recommended for use alongside components from @wordpress/components", and this note should be removed when the new components are stabilized.

Testing Instructions

  1. Visit the Storybook for this branch, either clicking the "Storybook preview" link in the "PR Meta" comment below, or by running npm run storybook:dev locally
  2. In Storybook, navigate to Components > @wordpress/components > Actions > Button > Migration Guide
  3. Review content for accuracy and helpfulness

Use of AI Tools

Implemented in coordination with Claude Code + Opus 5.5, with iterations based on my own review feedback and using contextual information from previous discussions about particular decisions:

@aduth
aduth requested a review from a team as a code owner December 3, 2026 21:44
@aduth aduth added [Type] Developer Documentation Documentation for developers [Package] Components /packages/components labels Dec 3, 2026
Copilot AI balanced review requested due to automatic review settings December 3, 2026 21:44
@github-actions

github-actions Bot commented Dec 3, 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: aduth <aduth@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 or WordPress.org 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.

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

As a user I want to be able to create a navigation overlay for a specific navigation block in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: /(Editor publish|Save panel)/ }).getByRole('button', { name: 'Save', exact: true })

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:48:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:91:4

36a8d80 Run

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.

🟡 Changes recommended

The migration guide omits icon conversions needed to prevent rendering errors, recommends inaccessible tooltips for additional information, and incorrectly states that custom icon sizing has no replacement.

3 open issues
What changed in this PR

Adds a Storybook guide for migrating legacy Button usage to @wordpress/ui ahead of stabilization.

Changes:

  • Maps legacy props and behaviors to replacement components, with examples.
  • Documents accessibility and styling differences without changing implementations or recommendation status.
File Description
packages/​components/​src/​button/​stories/​migration-guide.mdx Adds Button migration guidance and before-and-after examples.

Review effort: Balanced


### Icon with text

Replace the `icon` prop with a `Button.Icon` child. To show the icon after the text, put `Button.Icon` after the text. This replaces `iconPosition="right"`.
Comment on lines +171 to +180
`Button` has no `showTooltip` prop. A visible text label usually makes a tooltip unnecessary. If the tooltip gives more information, compose `Button` with `Tooltip`:

```jsx
import { Button, Tooltip } from '@wordpress/ui';

<Tooltip.Root>
<Tooltip.Trigger render={ <Button variant="outline" /> }>
Preview
</Tooltip.Trigger>
<Tooltip.Popup>Preview in a new tab</Tooltip.Popup>
</Button>;
```

`Button.Icon` always uses the same icon size. There is no replacement for `iconSize`.

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

[Package] Components /packages/components [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants