alpha

useDisclosureGroupState

Manages state for a group of disclosures, e.g. an accordion. It supports both single and multiple expanded items.

installyarn add react-stately
version3.33.1
usageimport {useDisclosureGroupState} from 'react-stately'

API#


useDisclosureGroupState( (props: DisclosureGroupProps )): DisclosureGroupState

Interface#


Properties

NameTypeDescription
allowsMultipleExpandedbooleanWhether multiple items can be expanded at the same time.
isDisabledbooleanWhether all items are disabled.
expandedKeysSet<Key>A set of keys for items that are expanded.

Methods

MethodDescription
toggleKey( (key: Key )): voidToggles the expanded state for an item by its key.
setExpandedKeys( (keys: Set<Key> )): voidReplaces the set of expanded keys.

Example#


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