useOverlayTriggerState

Manages state for an overlay trigger. Tracks whether the overlay is open, and provides methods to toggle this state.

installyarn add @react-stately/overlays
version3.2.0
usageimport {useOverlayTriggerState} from '@react-stately/overlays'

API#


useOverlayTriggerState( (props: OverlayTriggerProps )): OverlayTriggerState

Interface#


Properties

NameTypeDescription
isOpenbooleanWhether the overlay is currently open.

Methods

MethodDescription
setOpen( (isOpen: boolean )): voidSets whether the overlay is open.
open(): voidOpens the overlay.
close(): voidCloses the overlay.
toggle(): voidToggles the overlay's visibility.

Example#


See the docs for useOverlayTrigger in react-aria for an example of useOverlayTriggerState.