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/list
version3.4.4
usageimport {useSingleSelectListState} from '@react-stately/list'

API#


useSingleSelectListState<T>( (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.