alpha

useDisclosureState

Manages state for a disclosure widget. Tracks whether the disclosure is expanded, and provides methods to toggle this state.

installyarn add @react-stately/disclosure
version3.0.0-alpha.0
usageimport {useDisclosureState} from '@react-stately/disclosure'

API#


useDisclosureState( (props: DisclosureProps )): DisclosureState

Interface#


Properties

NameTypeDescription
isExpandedbooleanWhether the disclosure is currently expanded.

Methods

MethodDescription
setExpanded( (isExpanded: boolean )): voidSets whether the disclosure is expanded.
expand(): voidExpand the disclosure.
collapse(): voidCollapse the disclosure.
toggle(): voidToggles the disclosure's visibility.

Example#


See the docs for useDisclosure in react-aria for an example of useDisclosureState.