Skip to content

useButton API

API reference docs for the useButton hook. Learn about the input parameters and other APIs of this exported module.

Demos

For examples and details on the usage of this React hook, visit the demo pages:

Import

import useButton from '@mui/base/useButton';

Parameters

NameTypeDefaultDescription
disabledbooleanfalse
If true, the component is disabled.
focusableWhenDisabledbooleanfalse
If true, allows a disabled button to receive focus.
hrefstring
onFocusVisibleReact.FocusEventHandler
refReact.Ref<any>
tabIndexNonNullable<React.HTMLAttributes<any>['tabIndex']>
tostring
typeReact.ButtonHTMLAttributes<HTMLButtonElement>['type']'button'
Type attribute applied when the component is button.

Return value

NameTypeDefaultDescription
activebooleanfalse
If true, the component is active (pressed).
disabledbooleanfalse
If true, the component is disabled.
focusVisiblebooleanfalse
If true, the component is being focused using keyboard.
getRootProps<TOther extends EventHandlers = {}>(otherHandlers?: TOther) => UseButtonRootSlotProps<TOther>
Resolver for the root slot's props.
setFocusVisibleReact.Dispatch<React.SetStateAction<boolean>>
Callback for setting the focusVisible param.