The Unstyled Button component is composed of a root <button> slot with no interior slots:
<buttonclass="BaseButton-root"><!-- button text goes here --></button>
Slot props
Use the component prop to override the root slot with a custom element:
<ButtonUnstyledcomponent="div"/>
If you provide a non-interactive element such as a <span>, the Unstyled Button component will automatically add the necessary accessibility attributes.
Compare the attributes on the <span> in this demo with the Button from the previous demo—try inspecting them both with your browser's dev tools:
The useButton hook lets you apply the functionality of a button to a fully custom component.
It returns props to be placed on the custom component, along with fields representing the component's internal state.
The Unstyled Button accepts a wide range of custom elements beyond HTML elements.
You can even use SVGs, as the following demo illustrates:
Focus on disabled buttons
Similarly to the native HTML <button> element, the Unstyled Button component can't receive focus when it's disabled.
This may reduce its accessibility, as screen readers won't be able to announce the existence and state of the button.
The focusableWhenDisabled prop lets you change this behavior.
When this prop is set, the underlying button does not set the disabled prop.
Instead, aria-disabled is used, which makes the button focusable.
This should be used whenever the disabled button needs to be read by screen readers.
Base UI uses this prop internally in menu items, making it possible to use the keyboard to navigate to disabled items (in compliance with ARIA guidelines).
The following demo shows how the focusableWhenDisabled prop works—use the Tab key to navigate within this document to see that only the second button accepts the focus:
The focusableWhenDisabled prop works the same when the root slot is customized, except that the aria-disabled attribute is used no regardless of the prop's state.
The ability to receive focus is controlled internally by the tabindex attribute.