Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Button

The Button component lets a user perform an action or navigate to another location. Use its style to communicate the importance and consequence of the action.

Import

Inside a Payload Admin Panel Custom Component:

1
import { Button } from '@payloadcms/ui'

You can also import the component directly:

1
import { Button } from '@payloadcms/ui/elements/Button'

Basic usage

Use a primary button for the main action in a section or view.

Loading component example…

Styles

Use secondary for supporting actions. Use destructive when an action is destructive or difficult to reverse. The dashed, ghost, and pill variants provide lower-emphasis treatments for controls that need them.

Loading component example…

Avoid placing multiple primary buttons next to one another. When actions have equal emphasis, use secondary buttons instead.

Disabled state

Use disabled when an action is temporarily unavailable. When possible, explain what the user must do before the action becomes available.

Loading component example…

Sizes

Buttons support medium and large sizes. Use medium unless the surrounding interface establishes the larger size.

Loading component example…

Accessibility

  • Use a short, action-oriented label that describes what happens next.
  • Provide aria-label when an icon-only button has no visible label.
  • Do not rely on color alone to explain a destructive or disabled action.
  • Use type="submit" only when the button submits its containing form.
  • Use a link-style button for navigation rather than handling navigation in onClick.

Common props

These are the props most commonly used with this component. See its exported types in @payloadcms/ui for the complete list.

Prop

Type

Default

Description

buttonStyle

'primary' | 'secondary' | 'destructive' | 'dashed' | 'ghost' | 'pill'

'primary'

Sets the visual emphasis.

children

ReactNode

—

Visible button content.

disabled

boolean

false

Prevents interaction.

loading

boolean

false

Shows a spinner, hides the content, and prevents interaction.

margin

boolean

true

Applies the default outer margin.

round

boolean

false

Gives an icon button equal width and height.

selected

boolean

false

Applies the active treatment to supported variants.

size

'medium' | 'large'

'medium'

Sets the button height and spacing.

type

'button' | 'submit'

'button'

Sets the native button type.

Was this page helpful?

Next

Card