useMenuTriggerState

Manages state for a menu trigger. Tracks whether the menu is currently open, and controls which item will receive focus when it opens.

installyarn add @react-stately/menu
version3.0.0-alpha.1
usageimport {useMenuTriggerState} from '@react-stately/menu'

API#


useMenuTriggerState(props: MenuTriggerProps): MenuTriggerState

Interface#


Properties

NameTypeDescription
isOpenbooleanWhether the menu is currently open.
focusStrategyFocusStrategyControls which item will be auto focused when the menu opens.

Methods

MethodDescription
setOpen(value: boolean): voidSets whether the menu is open.
setFocusStrategy(value: FocusStrategy): voidSets which item will be auto focused when the menu opens.
open(): voidOpens the menu.
close(): voidCloses the menu.
toggle(focusStrategy: FocusStrategynull): voidToggles the menu.

Example#


See the docs for useMenuTrigger in react-aria for an example of useMenuTriggerState.