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.1
usageimport {useMenuTriggerState} from '@react-stately/menu'

API#


useMenuTriggerState( (props: )):

Interface#


Properties

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

Methods

MethodDescription
toggle( (focusStrategy: null )): voidToggles the menu.
open(): voidOpens the overlay.
close(): voidCloses the overlay.

Example#


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