useDisclosureState

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

installyarn add react-stately
version3.34.0
usageimport {useDisclosureState} from 'react-stately'

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.