Lets users take actions and make choices with a single click or tap.
import { Button } from '@wordpress/components';
LinksPermalink to this section
PropsPermalink to this section
| Name | Default | Description |
|---|---|---|
__next40pxDefaultSize | false |
Start opting into the larger default height that will become the default size in a future version. |
accessibleWhenDisabled | false |
Whether to keep the button focusable when disabled. In most cases, it is recommended to set this to Learn more about the focusability of disabled controls in the WAI-ARIA Authoring Practices Guide. |
children |
The button’s children. | |
description |
A visually hidden accessible description for the button. | |
icon |
If provided, renders an Icon component inside the button. | |
iconPosition | 'left' |
If provided with |
iconSize |
If provided with | |
isBusy |
Indicates activity while a action is being performed. | |
isDestructive |
Renders a red text-based button style to indicate destructive behavior. | |
isPressed |
Renders a pressed button style. | |
label |
Sets the | |
shortcut |
If provided with | |
showTooltip |
If provided, renders a Tooltip component for the button. | |
size | 'default' |
The size of the button.
If the deprecated |
text |
If provided, displays the given text inside the button. If the button contains children elements, the text is displayed before them. | |
tooltipPosition |
If provided with | |
variant |
Specifies the button’s style. The accepted values are:
| |
disabled |
Whether the button is disabled. If In most cases, it is recommended to also set the | |
__experimentalIsFocusable | false |
Whether to keep the button focusable when disabled. |
isDefault |
Gives the button a default style. | |
isLink |
Gives the button a link style. | |
isPrimary |
Gives the button a primary style. | |
isSecondary |
Gives the button a default style. | |
isTertiary |
Gives the button a text-based style. | |
isSmall |
Decreases the size of the button. | |
describedBy |
A visually hidden accessible description for the button. | |
href |
If provided, renders | |
target |
If provided with |
ExamplesPermalink to this section
DefaultPermalink to this section
const Default = ( props ) => {
return <Button __next40pxDefaultSize { ...props }></Button>;
};
PrimaryPermalink to this section
Primary buttons stand out with bold color fills, making them distinct from the background. Since they naturally draw attention, each layout should contain only one primary button to guide users toward the most important action.
const Primary = ( props ) => {
return <Button __next40pxDefaultSize { ...props }></Button>;
};
SecondaryPermalink to this section
Secondary buttons complement primary buttons. Use them for standard actions that may appear alongside a primary action.
const Secondary = ( props ) => {
return <Button __next40pxDefaultSize { ...props }></Button>;
};
TertiaryPermalink to this section
Tertiary buttons have minimal emphasis. Use them sparingly to subtly highlight an action.
const Tertiary = ( props ) => {
return <Button __next40pxDefaultSize { ...props }></Button>;
};
LinkPermalink to this section
Link buttons have low emphasis and blend into the page, making them suitable for supplementary actions, especially those involving navigation away from the current view.
const Link = ( props ) => {
return <Button __next40pxDefaultSize { ...props }></Button>;
};
Is DestructivePermalink to this section
Use this variant for irreversible actions. Apply sparingly and only for actions with significant impact.
const IsDestructive = ( props ) => {
return <Button __next40pxDefaultSize { ...props }></Button>;
};
IconPermalink to this section
const Icon = ( props ) => {
return <Button __next40pxDefaultSize { ...props }></Button>;
};
Grouped IconsPermalink to this section
function GroupedIcons() {
return (
<GroupContainer>
<Button __next40pxDefaultSize icon={ formatBold } label="Bold" />
<Button
__next40pxDefaultSize
icon={ formatItalic }
label="Italic"
/>
<Button __next40pxDefaultSize icon={ link } label="Link" />
</GroupContainer>
);
}