useMultipleSelectionState

Manages state for multiple selection and focus in a collection.

installyarn add @react-stately/selection
version3.0.0-alpha.1
usageimport {useMultipleSelectionState} from '@react-stately/selection'

Introduction#


useMultipleSelectionState manages selection state for many components. Oftentimes, you won't need to use this hook directly, since it's included in hooks like useListState, and useSelectState. These expose a SelectionManager, which provides a higher level way to manipulate selection state.

API#


useMultipleSelectionState(props: MultipleSelection): MultipleSelectionState

Interface#


Properties

NameTypeDescription
selectionModeSelectionMode
disallowEmptySelectionboolean
selectedKeysSet<Key>
isFocusedboolean
focusedKeyKey

Methods

MethodDescription
setSelectedKeys(keys: Set<Key>(v: Set<Key>) => Set<Key>): void
setFocused(isFocused: boolean): void
setFocusedKey(key: Key): void