useButton API
Demos
For examples and details on the usage of this React hook, visit the demo pages:
Import
import useButton from '@mui/base/useButton';Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false | If true, the component is disabled. |
| focusableWhenDisabled | boolean | false | If true, allows a disabled button to receive focus. |
| href | string | ||
| onFocusVisible | React.FocusEventHandler | ||
| ref | React.Ref<any> | ||
| tabIndex | NonNullable<React.HTMLAttributes<any>['tabIndex']> | ||
| to | string | ||
| type | React.ButtonHTMLAttributes<HTMLButtonElement>['type'] | 'button' | Type attribute applied when the component is button. |
Return value
| Name | Type | Default | Description |
|---|---|---|---|
| active | boolean | false | If true, the component is active (pressed). |
| disabled | boolean | false | If true, the component is disabled. |
| focusVisible | boolean | false | If true, the component is being focused using keyboard. |
| getRootProps | <TOther extends EventHandlers = {}>(otherHandlers?: TOther) => UseButtonRootSlotProps<TOther> | Resolver for the root slot's props. | |
| setFocusVisible | React.Dispatch<React.SetStateAction<boolean>> | Callback for setting the focusVisible param. |