An interface for reading and updating multiple selection state.
SelectionManager provides a generic interface for reading and
updating selection and focus state based on a
As discussed in the selection introduction, a selection is represented
by a Set of item keys. Focus
is represented by a single item key.
Focus state is updated when navigating a collection with the keyboard. Selection state is updated when a user
clicks or taps an item, or uses the keyboard to select an item. These interactions are handled by
useSelectableCollection hook in react-aria.
SelectionManager wraps the state returned by
Oftentimes, you won't need to construct these directly because hooks like
useTreeState already handle this and return
SelectionManager for you.
|The type of selection that is allowed in the collection.|
|Whether the collection allows empty selection.|
|The selection behavior for the collection.|
|Whether the collection is currently focused.|
|The current focused key in the collection.|
|Whether the first or last child of the focused key should receive focus.|
|The currently selected keys in the collection.|
The raw selection value for the collection. Either 'all' for select all, or a set of keys.
|Whether the selection is empty.|
|Whether all items in the collection are selected.|
|Sets the selection behavior for the collection.|
|Sets whether the collection is focused.|
|Sets the focused key.|
|Returns whether a key is selected.|
|Extends the selection to the given key.|
|Toggles whether the given key is selected.|
|Replaces the selection with only the given key.|
|Replaces the selection with the given keys.|
|Selects all items in the collection.|
|Removes all keys from the selection.|
|Toggles between select all and an empty selection.|
|Returns whether the current selection is equal to the given selection.|