Skip to content

Button

Buttons allow users to perform an action or to navigate to another page. They have multiple styles for various needs, and are ideal for calling attention to where a user needs to do something in order to move forward in a flow.

Variants

Primary Button

Primary buttons should be used sparingly, one per screen, as they are used to guide the user towards taking a primary action.

<Button variant="primary">Create user</Button>

Secondary Button

Secondary buttons add less emphasis and often accompany primary buttons in button groups, like the side panel footer.

<Button variant="secondary">Sync profile</Button>

Tertiary Button

Tertiary buttons are used for actions requiring less emphasis.

<Button variant="tertiary">Cancel</Button>

Critical Button

Crtical buttons are used for actions that require the most emphasis, as they are used to guide the user towards taking a destructive or potentially dangerous action.

<Button variant="critical">Delete user</Button>

Props

interface ButtonProps
variant ? "critical" | "primary" | "secondary" | "tertiary" | null

Changes the appearance of the button.

Defaults to secondary
isPending ? boolean

Whether the button is in a pending state. This disables press and hover events while retaining focusability, and announces the pending state to screen readers.

isDisabled ? boolean

Whether the button is disabled.

onPress ? (e: PressEvent) => void

Handler that is called when the press is released over the target.

onPressStart ? (e: PressEvent) => void

Handler that is called when a press interaction starts.

onPressEnd ? (e: PressEvent) => void

Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.

onPressChange ? (isPressed: boolean) => void

Handler that is called when the press state changes.

onPressUp ? (e: PressEvent) => void

Handler that is called when a press is released over the target, regardless of whether it started on the target or not.

onClick ? (e: MouseEvent) => void

Not recommended – use onPress instead. onClick is an alias for onPress provided for compatibility with other libraries. onPress provides additional event details for non-mouse interactions.

autoFocus ? boolean

Whether the element should receive focus on render.

onFocus ? (e: FocusEvent) => void

Handler that is called when the element receives focus.

onBlur ? (e: FocusEvent) => void

Handler that is called when the element loses focus.

onFocusChange ? (isFocused: boolean) => void

Handler that is called when the element's focus status changes.

onKeyDown ? (e: KeyboardEvent) => void

Handler that is called when a key is pressed.

onKeyUp ? (e: KeyboardEvent) => void

Handler that is called when a key is released.

type ? "button" | "submit" | "reset"

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

Defaults to 'button'
preventFocusOnPress ? boolean

Whether to prevent focus from moving to the button when pressing it.

Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's increment/decrement control.

form ? string

The <form> element to associate the button with. The value of this attribute must be the id of a <form> in the same document. See MDN.

formAction ? string

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

formEncType ? string

Indicates how to encode the form data that is submitted.

formMethod ? string

Indicates the HTTP method used to submit the form.

formNoValidate ? boolean

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

formTarget ? string

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

name ? string

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

value ? string

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

excludeFromTabOrder ? boolean

Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available.

id ? string

The element's unique identifier. See MDN.

onHoverStart ? (e: HoverEvent) => void

Handler that is called when a hover interaction starts.

onHoverEnd ? (e: HoverEvent) => void

Handler that is called when a hover interaction ends.

onHoverChange ? (isHovering: boolean) => void

Handler that is called when the hover state changes.

slot ? string | null

A slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.

children ? ChildrenOrFunction

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

className ? ClassNameOrFunction

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

style ? StyleOrFunction

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