Button
Buttons let users take actions and make choices with a single tap.
useButton API
Import
import useButton from '@mui/base/useButton';
// or
import { useButton } from '@mui/base';
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 | ||
rootRef | React.Ref<Element> | ||
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 | Description |
---|---|---|
active | boolean | If true , the component is active (pressed). |
focusVisible | boolean | If true , the component is being focused using keyboard. |
getRootProps | <TOther extends EventHandlers = {}>(otherHandlers?: TOther) => UseButtonRootSlotProps<TOther> | Resolver for the root slot's props. |
rootRef | React.RefCallback<Element> | null | A ref to the component's root DOM element. |
setFocusVisible | React.Dispatch<React.SetStateAction<boolean>> | Callback for setting the focusVisible param. |