React Aria and React Spectrum have a new home!
useOverlayTriggerState
Manages state for an overlay trigger. Tracks whether the overlay is open, and provides methods to toggle this state.
| install | yarn add react-stately |
|---|---|
| version | 3.42.0 |
| usage | import {useOverlayTriggerState} from 'react-stately' |
API#
useOverlayTriggerState(
(props: OverlayTriggerProps
)): OverlayTriggerState
Interface#
Properties
| Name | Type | Description |
isOpen | boolean | Whether the overlay is currently open. |
Methods
| Method | Description |
setOpen(
(isOpen: boolean
)): void | Sets whether the overlay is open. |
open(): void | Opens the overlay. |
close(): void | Closes the overlay. |
toggle(): void | Toggles the overlay's visibility. |
Example#
See the docs for usePopover in react-aria for an example of useOverlayTriggerState.