React Aria and React Spectrum have a new home!
useDisclosureGroupState
Manages state for a group of disclosures, e.g. an accordion. It supports both single and multiple expanded items.
| install | yarn add react-stately |
|---|---|
| version | 3.42.0 |
| usage | import {useDisclosureGroupState} from 'react-stately' |
API#
useDisclosureGroupState(
(props: DisclosureGroupProps
)): DisclosureGroupState
Interface#
Properties
| Name | Type | Description |
allowsMultipleExpanded | boolean | Whether multiple items can be expanded at the same time. |
isDisabled | boolean | Whether all items are disabled. |
expandedKeys | Set<Key> | A set of keys for items that are expanded. |
Methods
| Method | Description |
toggleKey(
(key: Key
)): void | Toggles the expanded state for an item by its key. |
setExpandedKeys(
(keys: Set<Key>
)): void | Replaces the set of expanded keys. |
Example#
See the docs for useDisclosure in react-aria for an example of useDisclosureGroupState.