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/disclosure
version3.0.0-alpha.0
usageimport {useDisclosureGroupState} from '@react-stately/disclosure'

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.