Button
A button component that can be rendered as another tag or focusable when disabled.
View as MarkdownAnatomy
Import the component:
import { Button } from '@base-ui/react/button';
<Button />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}.
import { Button } from '@base-ui/react/button';
<Button render={<div />} nativeButton={false}>
Button that can contain complex children
</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.
API reference
focusableWhenDisabledbooleanfalse
- Description
Whether the button should be focusable when disabled.
- Type
boolean | undefined- Default
false
nativeButtonbooleantrue
- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (e.g.<div>).- Type
boolean | undefined- Default
true
classNamestring | function—
- Name
- 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)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | ((state: Button.State) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | ((props: HTMLProps, state: Button.State) => ReactElement)