React Aria and React Spectrum have a new home!
useDisclosureState
Manages state for a disclosure widget. Tracks whether the disclosure is expanded, and provides methods to toggle this state.
| install | yarn add react-stately |
|---|---|
| version | 3.42.0 |
| usage | import {useDisclosureState} from 'react-stately' |
API#
useDisclosureState(
(props: DisclosureProps
)): DisclosureState
Interface#
Properties
| Name | Type | Description |
isExpanded | boolean | Whether the disclosure is currently expanded. |
Methods
| Method | Description |
setExpanded(
(isExpanded: boolean
)): void | Sets whether the disclosure is expanded. |
expand(): void | Expand the disclosure. |
collapse(): void | Collapse the disclosure. |
toggle(): void | Toggles the disclosure's visibility. |
Example#
See the docs for useDisclosure in react-aria for an example of useDisclosureState.