Button

Displays a button or a link that looks like a button.

View as Markdown

Installation

Usage

Variant

Use the variant prop to set how much the button stands out. Use one primary per view.

Color

Use color="danger" for an action that deletes or destroys. Every variant takes it without changing its shape; primary draws the same tint as secondary.

Size

Use the size prop to change the size of the button.

Icon Only

Use an icon-* size for a button with only an icon. Add an aria-label.

With Icon

Add data-icon="inline-start" or data-icon="inline-end" to the icon for the correct spacing. Use sizes.iconXs at xs, sizes.iconSm at sm and sizes.icon otherwise.

Corners

Buttons are pills by default. Use corners="rounded" for the theme's control corner, radii.sm.

Use buttonStyles to make a link look like a button.

Don't use <Button render={<a />} nativeButton={false} /> for links. Base UI's Button always sets role="button", so screen readers announce it as a button, not a link.

Disabled

Use disabled when the action isn't available. It fades the button and shows a not-allowed cursor.

Busy

Add aria-busy while something runs. It shows a busy cursor, so working reads differently from unavailable. What goes inside is up to you.

  • With disabled, it's loading: it fades less than disabled and can't be pressed twice.
  • Alone, it stays pressable at full strength, for a button that acts on the running work: press Generate, and the same button becomes Stop generating.

API Reference

Button

Takes every prop of Base UI's Button, plus:

buttonStyles

Returns the button's styles for stylex.props. Takes variant, color, size and corners, with the same defaults.