Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
97e9a5a
UI: add link button
simison Jun 4, 2026
1cf917e
Update CHANGELOG.md
simison Jun 4, 2026
5310cb4
Add guidance
simison Jun 5, 2026
e901e2d
Update guidelines
simison Jun 5, 2026
a35beac
Update guidance copy
simison Jun 5, 2026
cb145a8
Fix quick reference table
simison Jun 5, 2026
9c4c419
Add LinkButton defence style
simison Jun 5, 2026
35e0041
Remove disabled state
simison Jun 5, 2026
0fd3ebb
Update style.module.css
simison Jun 5, 2026
6f7ddc8
re-layer
simison Jun 23, 2026
2bdf9d5
Don't cut lines in markdown
simison Jun 25, 2026
b7e3c9a
Update token in storybook
simison Jun 25, 2026
ab40fa1
Update packages/ui/src/button/stories/usage-guidelines.mdx
simison Jun 25, 2026
de47f5d
Fix link in storybook
simison Jun 25, 2026
08b339b
Fix another link in storybook
simison Jun 25, 2026
664c9a9
Use `a` defence styles
simison Jun 25, 2026
87ae26b
Comments cleanup
simison Jun 25, 2026
fa47678
Add a thin LinkButtonIcon wrapper
simison Jun 25, 2026
4c70ad6
Use JSDoc to link to guidelines
simison Jun 25, 2026
b9d0ba5
Update CHANGELOG.md
simison Jun 25, 2026
7d26ad8
Implement using Link
simison Jun 30, 2026
14c6eee
Remove un-used componentStatus from guideline doc
simison Jun 30, 2026
f444f3d
Include IconButton along Button in "Usage guidelines"
simison Jun 30, 2026
9a11dfe
Update packages/ui/src/button/stories/usage-guidelines.mdx
simison Jul 1, 2026
b142e5f
Simplify types, href is now optional
simison Jul 1, 2026
13a8f8a
Move --_gcd-a-color overrides to compositions layer
simison Jul 1, 2026
9007ae8
Update packages/ui/src/button/stories/usage-guidelines.mdx
simison Jul 1, 2026
c599184
Update packages/ui/src/button/stories/usage-guidelines.mdx
simison Jul 1, 2026
63a1c50
Update packages/ui/src/button/stories/usage-guidelines.mdx
simison Jul 1, 2026
acbf582
Remove reduntant tests
simison Jul 2, 2026
73727a3
Let render and openInNewTab spread as part of props
simison Jul 2, 2026
1d89e01
Remove reduntant focus style; its now provided Link
simison Jul 2, 2026
5403316
Reset border-radius back to button's rounded
simison Jul 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- Add `LinkButton` component ([#78944](https://github.com/WordPress/gutenberg/pull/78944)).

### Bug Fixes

- `IconButton`: Keep the inline padding override valid when reused in button length calculations ([#79722](https://github.com/WordPress/gutenberg/pull/79722)).
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import defenseStyles from '../utils/css/global-css-defense.module.css';

/**
* A versatile button component with multiple variants, tones, and sizes.
*
* See the [Usage Guidelines](https://wordpress.github.io/gutenberg/?path=/docs/design-system-components-button-usage-guidelines--docs)
* for when to use `Button`, `IconButton`, `Link`, or `LinkButton`.
*/
export const Button = forwardRef< HTMLButtonElement, ButtonProps >(
function Button(
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ ButtonIcon.displayName = 'Button.Icon';

/**
* A versatile button component with multiple variants, tones, and sizes.
*
* See the [Usage Guidelines](https://wordpress.github.io/gutenberg/?path=/docs/design-system-components-button-usage-guidelines--docs)
* for when to use `Button`, `IconButton`, `Link`, or `LinkButton`.
*/
export const Button = Object.assign( _Button, {
/**
Expand Down
76 changes: 76 additions & 0 deletions packages/ui/src/button/stories/usage-guidelines.mdx
Comment thread
ciampo marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Canvas, Markdown, Meta } from '@storybook/addon-docs/blocks';
import * as UsageGuidelinesStories from './usage-guidelines.story';

<Meta of={ UsageGuidelinesStories } />

# Button, IconButton, Link, and LinkButton

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One nuance that comes up in modern web apps are actions that change the URL but don't push an item onto the history stack. A common example would be a button that opens some kind of dialog or panel, and that new view has a permalink that is replaceStack()ed (instead of push) to the history stack. We actually need to use button semantics in this case. "Navigate" is a somewhat ambiguous term in an SPA-context to begin with, so the most accurate criteria for choosing between button/link is going to be "does it push a new item onto the history stack".

It's perhaps a bit of an advanced concept to use as our basic guideline, but we might want to capture this nuance somewhere in this doc as well.

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.

Yeah; I also don't also want to make document too technical sounding since one audience should be designers who necessarily don't know what we mean by technical descriptions like you're suggesting.

Agree that "Navigation" is vague, or the whole topic is vague;

  • SPAs can usually navigate with onClick or href just fine
  • Buttons opening modals, filter buttons, etc can set state in URL, e.g. #modal-open, ?filters= which can intentionally be part of history stack.

Perhaps there's a way to think and frame "navigate" entirely as non non-technical term, but I'm not sure how to phrase it. Good as-is for now and we can always iterate?


Choose the component based on **what happens when the user activates it**, not only on how it should look.

## Quick reference

<Markdown>{ `
| Goal | Component | Element | Examples |
| --- | --- | --- | --- |
| Performs an action on the current page | [Button](?path=/docs/design-system-components-button--docs), [IconButton](?path=/docs/design-system-components-iconbutton--docs) | \`<button>\` | Save, Delete, Submit, toolbar icon actions |
| Navigate to another page or URL | [Link](?path=/docs/design-system-components-link--docs) | \`<a>\` | "Learn more", docs links, external references |
| Navigate with button styling | [LinkButton](?path=/docs/design-system-components-linkbutton--docs) | \`<a>\` | Standalone CTAs, card actions |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"card actions" reads as a bit ambiguous/contradictory for an example for links. What specifically did we mean here?

@simison simison Jul 2, 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.

This type of card with links seems pretty common:

image

Since they're primary CTAs, folks don't want to use Link for visual reasons; a button carries more "CTA feel" and is more noticeable.

Standalone would be more like what could be in EmptyState in the middle of the page:

image

Word are hard, and visual examples help. :-) I want to revisit this guide in a follow-up with clearer do/don't illustrations and "Do/Don't do" sections (similar to what I did in Badge) , but I think it's better for a follow-up.

` }</Markdown>

## Use `Button` and `IconButton` for actions

Use `Button` or `IconButton` when activation should **not** navigate away as a link would:

- Submitting or resetting a form (`type="submit"` / `type="reset"`)
- Opening overlays ([Dialog](?path=/docs/design-system-components-dialog--docs), [Popover](?path=/docs/design-system-components-popover--docs), etc.)
- Running JavaScript on the current page (`onClick` without a meaningful `href`)
- Toggle controls (`aria-pressed` on neutral minimal buttons)
- Showing a **loading** state while an async action completes

Use [IconButton](?path=/docs/design-system-components-iconbutton--docs) for the same kinds of actions when the control is **icon-only** — for example, toolbar buttons. It inherits `Button` props and adds a built-in tooltip via the required `label` prop (used as the accessible name).

`Button` and `IconButton` use button semantics. Do not use them as stand-ins for navigation when a real URL is the primary outcome.

<Canvas of={ UsageGuidelinesStories.UseButtonForActions } />

See [Button](?path=/docs/design-system-components-button--docs) and [IconButton](?path=/docs/design-system-components-iconbutton--docs) for API details and examples.

## Use `Link` for navigation

Use `Link` when activation should take the user to another page or URL. This is the default choice for navigation — not just inline references in running text, but any case where the outcome is “go somewhere else.”

`Link` styling communicates navigation more clearly than a button-shaped control. Users can see at a glance that they are following a link, not triggering an action on the current page.

Typical uses:

- Inline references inside [Text](?path=/docs/design-system-components-text--docs) or paragraphs
- Standalone “Learn more”, “View documentation”, or “Open site” actions
- External destinations with `openInNewTab` (adds `target="_blank"` and an accessible new-tab indicator)

Compose `Text` as the host and `Link` via `render` when you need typography from `Text` on a standalone link.

<Canvas of={ UsageGuidelinesStories.UseLinkForInlineNavigation } />

See [Link](?path=/docs/design-system-components-link--docs) for API details and examples.

## Use `LinkButton` for navigation with button styling

Use `LinkButton` when the destination is a **URL** and the control should **look like a `Button`** — for example, standalone calls to action, card footers, or notice actions where button weight fits the layout.

`LinkButton` shares `Button` visual props (`variant`, `tone`, `size`) but renders an `<a>` like `Link`. Use `openInNewTab` for external destinations (adds `target="_blank"` and an accessible new-tab indicator). It does **not** support `disabled`, `loading`, `focusableWhenDisabled`, `nativeButton`, or toggle `aria-pressed`.

Do **not** use `LinkButton` for form submit, dialogs, or other non-navigation actions — use `Button` instead.

Do **not** use `Button` with `render={ <a href="…" /> }` and `nativeButton={ false }` for new code when `LinkButton` fits; `LinkButton` is the supported pattern for button-styled links.

<Canvas of={ UsageGuidelinesStories.UseLinkButtonForNavigation } />

> **Note:** Prefer `Link` for navigation when possible. Its underline and link styling communicate where the user is going more clearly than a button-shaped control. Reach for `LinkButton` only when you have considered `Button` and `Link` and still need button prominence.

See [LinkButton](?path=/docs/design-system-components-linkbutton--docs) for API details and examples.

## Common mistakes

- **`Button` or `IconButton` + `onClick` for navigation** — Prefer `Link` with a real `href` so keyboard, assistive technology, and browser link affordances stay correct.
- **`LinkButton` when `Link` would work** — Default to `Link` for navigation; button styling can obscure that the control goes elsewhere.
- **`LinkButton` for submit or toggle actions** — Use `Button` or `IconButton`, depending on whether the control needs a visible text label or is icon-only; `LinkButton` does not support loading or pressed toggle styling.
106 changes: 106 additions & 0 deletions packages/ui/src/button/stories/usage-guidelines.story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import type { Meta, StoryObj } from '@storybook/react-vite';
import { createInterpolateElement } from '@wordpress/element';
import { cog } from '@wordpress/icons';
import { Button } from '../index';
import { IconButton } from '../../icon-button';
import { Link } from '../../link';
import { LinkButton } from '../../link-button';
import { Stack } from '../../stack';
import { Text } from '../../text';
import * as Tooltip from '../../tooltip';

const meta: Meta = {
title: 'Design System/Components/Button/Usage Guidelines',
parameters: {
controls: { disable: true },
},
tags: [ '!dev' ],
};
export default meta;

type Story = StoryObj;

/**
* Use `Button` or `IconButton` for actions on the current view: submitting a
* form, opening a dialog, toggling UI, or running JavaScript. Both render a
* `<button>` and support loading and pressed states.
*/
export const UseButtonForActions: Story = {
render: () => (
<Tooltip.Provider delay={ 0 }>
<Stack direction="row" gap="sm" wrap="wrap" align="center">
<Button type="submit">Save changes</Button>
<Button variant="outline" onClick={ () => {} }>
Settings
</Button>
<IconButton
icon={ cog }
label="Settings"
variant="outline"
onClick={ () => {} }
/>
</Stack>
</Tooltip.Provider>
),
};

/**
* Use `Link` for navigation. Its underline and link styling communicate where
* the user is going more clearly than a button-shaped control.
*/
export const UseLinkForInlineNavigation: Story = {
render: () => (
<Text variant="body-md" render={ <p /> }>
{ createInterpolateElement(
'Read the <DocumentationLink /> for more details, or <ExternalLink />.',
{
DocumentationLink: (
<Link href="https://wordpress.org/documentation/">
documentation
</Link>
),
ExternalLink: (
<Link href="https://make.wordpress.org/" openInNewTab>
open an external reference
</Link>
),
}
) }
</Text>
),
};

/**
* Use `LinkButton` when navigation should look like a `Button`, such as
* standalone calls to action that require an `href`.
*
* Note: Prefer `Link` for navigation when possible. Its underline and link
* styling set clearer expectations than a button-shaped control.
*/
export const UseLinkButtonForNavigation: Story = {
render: () => (
<Stack direction="column" gap="md">
<Text variant="body-md" render={ <p /> }>
Standalone navigation calls to action can use `LinkButton` when
button styling matches the surrounding UI.
</Text>
<div>
<LinkButton href="https://make.wordpress.org/" openInNewTab>
Get started
</LinkButton>
</div>
<Text variant="body-md" render={ <p /> }>
{ createInterpolateElement(
'Note: Prefer <LinkComponent /> for navigation when possible — its underline and link styling communicate where the user is going more clearly than a button-shaped control.',
{
LinkComponent: (
<Link href="https://wordpress.org/documentation/">
Link
</Link>
),
}
) }
</Text>
</Stack>
),
};
3 changes: 3 additions & 0 deletions packages/ui/src/icon-button/icon-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { type IconButtonProps } from './types';
*
* When rendering a group of `IconButton`s, wrap them in a `Tooltip.Provider`
* to coordinate tooltip delays across the group.
*
* See the [Usage Guidelines](https://wordpress.github.io/gutenberg/?path=/docs/design-system-components-button-usage-guidelines--docs)
* for when to use `Button`, `IconButton`, `Link`, or `LinkButton`.
*/
export const IconButton = forwardRef< HTMLButtonElement, IconButtonProps >(
function IconButton(
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './form';
export * from './icon';
export * from './icon-button';
export * from './link';
export * from './link-button';
export * as Notice from './notice';
export * as Popover from './popover';
export * from './stack';
Expand Down
9 changes: 9 additions & 0 deletions packages/ui/src/link-button/icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { forwardRef } from '@wordpress/element';
import { ButtonIcon } from '../button/icon';
import { type LinkButtonIconProps } from './types';

export const LinkButtonIcon = forwardRef< SVGSVGElement, LinkButtonIconProps >(
function LinkButtonIcon( props, ref ) {
return <ButtonIcon ref={ ref } { ...props } />;
}
);
21 changes: 21 additions & 0 deletions packages/ui/src/link-button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { LinkButton as _LinkButton } from './link-button';
import { LinkButtonIcon } from './icon';

export type { LinkButtonProps, LinkButtonIconProps } from './types';

LinkButtonIcon.displayName = 'LinkButton.Icon';

/**
* A link that looks like a `Button`. Prefer `Link` for navigation unless
* button prominence is intentional.
Comment thread
simison marked this conversation as resolved.
Resolved
*
* See the [Usage Guidelines](https://wordpress.github.io/gutenberg/?path=/docs/design-system-components-button-usage-guidelines--docs)
* for when to use `Button`, `IconButton`, `Link`, or `LinkButton`.
*/
export const LinkButton = Object.assign( _LinkButton, {
/**
* An icon component specifically designed to work well when rendered inside
* a `LinkButton` component.
*/
Icon: LinkButtonIcon,
} );
47 changes: 47 additions & 0 deletions packages/ui/src/link-button/link-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import clsx from 'clsx';
import { forwardRef } from '@wordpress/element';
import { Link } from '../link';
import { type LinkButtonProps } from './types';
import buttonStyles from '../button/style.module.css';
import focusStyles from '../utils/css/focus.module.css';
import styles from './style.module.css';

/**
* A link that looks like a `Button`. Prefer `Link` for navigation unless
* button prominence is intentional.
*
* See the [Usage Guidelines](https://wordpress.github.io/gutenberg/?path=/docs/design-system-components-button-usage-guidelines--docs)
* for when to use `Button`, `IconButton`, `Link`, or `LinkButton`.
*/
export const LinkButton = forwardRef< HTMLAnchorElement, LinkButtonProps >(
function LinkButton(
{
tone = 'brand',
variant = 'solid',
size = 'default',
className,
children,
...props
},
ref
) {
return (
<Link
ref={ ref }
variant="unstyled"
className={ clsx(
styles[ 'link-button' ],
focusStyles[ 'outset-ring--focus-except-active' ],
Comment thread
simison marked this conversation as resolved.
Resolved
variant !== 'unstyled' && buttonStyles.button,
buttonStyles[ `is-${ tone }` ],
buttonStyles[ `is-${ variant }` ],
buttonStyles[ `is-${ size }` ],
className
) }
{ ...props }
>
{ children }
</Link>
);
}
);
Loading
Loading