useOverlayTriggerState

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

installyarn add react-stately
version3.27.1
usageimport {useOverlayTriggerState} from 'react-stately'

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 usePopover in react-aria for an example of useOverlayTriggerState.