Button

A button allows a user to initiate an action.

Anatomy

Composed Components

A Button uses the following components.

Usage

Variants

A button can use different variants.

Primary - For the principal call to action on the page. Primary buttons should only appear once per screen — not including the application header, modal or side panel.

Secondary - For secondary actions on each page. Secondary buttons can be used in conjunction with a primary button or on its own. Paired with a Primary button, the secondary button usually performs the negative action of the set, such as “Cancel.”

Upsell - For upsell actions that relate to upgrading an account or a plan. Use the upsell button to distinguish it from an existing primary button. In some cases, a primary button can be used instead when the general context of the page is about upselling.

Danger - For actions that could have destructive effects on the user’s data.

Ghost-[primary|secondary|danger] - For less prominent, and sometimes independent, actions. Ghost buttons can be used in isolation or paired with a primary button when there are multiple calls to action. Ghost buttons can also be used for subtasks on a page where a primary button for the main and final action is present.

Sizes

A button can vary in size.

Disabled

A button can be disabled.

Loading

A button can show a loading indicator. The button text is hidden but the button maintains the width that it would have if the text were visible.

Fluid

A button can be expanded to full width to fill its parent container.

Icon Only

A button can contain only an icon.

Icon

A button can contain icons.

End Icon

Nonstandard end icons can be provided to handle special cases. However, think twice before adding end icons, start icons should be your go-to.

Props

variant?

The visual style of the button.

Defaults to primary.
size?

A button can vary in size.

Defaults to md.
isFluid?

Whether or not the button takes up the width of its container.

isLoading?

A button can show a loading indicator.

spinnerProps?

The props for the Spinner.

form?

The element to associate the button with. The value of this attribute must be the id of a in the same document.

style?

The inline style for the element. A function may be provided to compute the style based on component state.

children?

The children of the component. A function may be provided to alter the children based on component state.

isDisabled?

Whether the button is disabled.

autoFocus?

Whether the element should receive focus on render.

type?

The behavior of the button when used in an HTML form.

Defaults to 'button'.
id?

The element's unique identifier. See MDN.

formAction?

The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner.

formEncType?

Indicates how to encode the form data that is submitted.

formMethod?

Indicates the HTTP method used to submit the form.

formNoValidate?

Indicates that the form is not to be validated when it is submitted.

formTarget?

Overrides the target attribute of the button's form owner.

name?

Submitted as a pair with the button's value as part of the form data.

value?

The value associated with the button's name when it's submitted with the form data.

className?

The CSS className for the element. A function may be provided to compute the class based on component state.

Migration Notes

Coming from Orbiter, you should be aware of the following changes:

  • onClick has been renamed to onPress to be closer to the React Aria API.
  • Counter is no longer allowed as a specialized slot.
  • ButtonAsLink is renamed to LinkButton.
  • IconButton is now integrated into the Button component.
  • as(Button, ReactRouterLink) is now integrated into the Button component.