useMenuTriggerState
Manages state for a menu trigger. Tracks whether the menu is currently open, and controls which item will receive focus when it opens.
| install | yarn add @react-stately/menu |
|---|---|
| version | 3.0.0-alpha.1 |
| usage | import {useMenuTriggerState} from '@react-stately/menu' |
API#
useMenuTriggerState(props: MenuTriggerProps): MenuTriggerStateInterface#
Properties
| Name | Type | Description |
isOpen | boolean | Whether the menu is currently open. |
focusStrategy | FocusStrategy | Controls which item will be auto focused when the menu opens. |
Methods
| Method | Description |
setOpen(value: boolean): void | Sets whether the menu is open. |
setFocusStrategy(value: FocusStrategy): void | Sets which item will be auto focused when the menu opens. |
open(): void | Opens the menu. |
close(): void | Closes the menu. |
toggle(focusStrategy: FocusStrategy | null): void | Toggles the menu. |
Example#
See the docs for useMenuTrigger in react-aria for an example of useMenuTriggerState.