Button

A button component that can be rendered as another tag or focusable when disabled.

View as Markdown

Anatomy

Import the component:

Anatomy

API reference

focusableWhenDisabled

boolean

false

Description

Whether the button should be focusable when disabled.

Type
boolean | undefined
Default

false

nativeButton

boolean

Type
boolean | undefined
style

React.CSSProperties | function

Name
Type
| React.CSSProperties
| ((state: Button.State) => CSSProperties | undefined)
| undefined
disabled

boolean

Description

Whether the button should ignore user interaction.

Type
boolean | undefined
className

string | function

Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
| string
| ((state: Button.State) => string | undefined)
render

ReactElement | function

Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
| ReactElement
| ((props: HTMLProps, state: Button.State) => ReactElement)
data-disabled

Present when the button is disabled.

Examples

Rendering as another tag

The button can remain keyboard accessible while being rendered as another tag, such as a <div>, by specifying nativeButton={false}.

Custom tag button

Loading states

For buttons that enter a loading state after being clicked, specify the focusableWhenDisabled prop to ensure focus remains on the button when it becomes disabled. This prevents focus from being lost and maintains the tab order.