useMultipleSelectionState

Manages state for multiple selection and focus in a collection.

installyarn add @react-stately/selection
version3.0.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

, and . These expose a SelectionManager, which provides a higher level way to manipulate selection state.

API#


useMultipleSelectionState( (props: )):

Interface#


Properties

NameTypeDescription
selectionModeThe type of selection that is allowed in the collection.
disallowEmptySelectionbooleanWhether the collection allows empty selection.
selectedKeysThe currently selected keys in the collection.
isFocusedbooleanWhether the collection is currently focused.
focusedKeyKeyThe current focused key in the collection.

Methods

MethodDescription
setSelectedKeys( (keys: ( (v: )) => )): voidSets the selected keys in the collection.
setFocused( (isFocused: boolean )): voidSets whether the collection is focused.
setFocusedKey( (key: Key )): voidSets the focused key.