useMultipleSelectionState
Manages state for multiple selection and focus in a collection.
| install | yarn add react-stately |
|---|---|
| version | 3.47.0 |
| usage | import {useMultipleSelectionState} from 'react-stately' |
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: MultipleSelectionStateProps
)): MultipleSelectionState
Interface#
Properties
| Name | Type | Description |
selectionMode | SelectionMode | The type of selection that is allowed in the collection. |
selectionBehavior | SelectionBehavior | The selection behavior for the collection. |
disallowEmptySelection | boolean | Whether the collection allows empty selection. |
selectedKeys | Selection | The currently selected keys in the collection. |
disabledKeys | Set<Key> | The currently disabled keys in the collection. |
disabledBehavior | DisabledBehavior | Whether disabledKeys applies to selection, actions, or both. |
isFocused | boolean | Whether the collection is currently focused. |
focusedKey | Key | null | The current focused key in the collection. |
childFocusStrategy | FocusStrategy | null | Whether the first or last child of the focused key should receive focus. |
Methods
| Method | Description |
setSelectionBehavior(
(selectionBehavior: SelectionBehavior
)): void | Sets the selection behavior for the collection. |
setSelectedKeys(
(keys: Selection
)): void | Sets the selected keys in the collection. |
setFocused(
(isFocused: boolean
)): void | Sets whether the collection is focused. |
setFocusedKey(
(key: Key
| | null,
, child?: FocusStrategy
)): void | Sets the focused key, and optionally, whether the first or last child of that key should receive focus. |