useSingleSelectListState

Provides state management for list-like components with single selection. Handles building a collection of items from props, and manages selection state.

installyarn add react-stately
version3.17.0
usageimport {useSingleSelectListState} from 'react-stately'

API#


useSingleSelectListState<T extends object>( (props: SingleSelectListProps<T> )): SingleSelectListState<T>

Interface#


Properties

NameTypeDescription
selectedKeyKeyThe key for the currently selected item.
selectedItemNode<T>The value of the currently selected item.
collectionCollection<Node<T>>A collection of items in the list.
disabledKeysSet<Key>A set of items that are disabled.
selectionManagerSelectionManagerA selection manager to read and update multiple selection state.

Methods

MethodDescription
setSelectedKey( (key: Key )): voidSets the selected key.