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/overlays |
---|---|
version | 3.0.0 |
usage | import {useOverlayTriggerState} from '@react-stately/overlays' |
API#
useOverlayTriggerState(
(props:
)):
Interface#
Properties
Name | Type | Description |
isOpen | boolean | Whether the overlay is currently open. |
Methods
Method | Description |
open(): void | Opens the overlay. |
close(): void | Closes the overlay. |
toggle(): void | Toggles the overlay's visibility. |
Example#
See the docs for useOverlayTrigger in react-aria for an example of useOverlayTriggerState
.
Name | Type | Description |
isOpen | boolean | Whether the overlay is open by default (controlled). |
defaultOpen | boolean | Whether the overlay is open by default (uncontrolled). |
onOpenChange | (
(isOpen: boolean
)) => void | Handler that is called when the overlay's open state changes. |
Properties
Name | Type | Description |
isOpen | boolean | Whether the overlay is currently open. |
Methods
Method | Description |
open(): void | Opens the overlay. |
close(): void | Closes the overlay. |
toggle(): void | Toggles the overlay's visibility. |