useMultipleSelectionState

Manages state for multiple selection and focus in a collection.

installyarn add @react-stately/selection
version3.3.0
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
selectionModeSelectionModeThe type of selection that is allowed in the collection.
disallowEmptySelectionbooleanWhether the collection allows empty selection.
selectedKeysSelectionThe currently selected keys in the collection.
disabledKeysSet<Key>The currently disabled keys in the collection.
isFocusedbooleanWhether the collection is currently focused.
focusedKeyKeyThe current focused key in the collection.

Methods

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