useTableSelectionState@astryxdesign/core v0.5.2 · useTableSelectionState

Usage

State management companion for useTableSelection. Handles disabled/selectable row filtering for select-all automatically: disabled rows are frozen (preserved across select-all/deselect-all), non-selectable rows are excluded.

ts
import {useTableSelectionState} from '@astryxdesign/core/Table'

Parameters

ParamTypeDescription
datarequired
T[]

The full data array rendered in the table.

idKeyrequired
(keyof T & string) | ((item: T) => string)

Key extractor: property name or function returning a unique string ID.

selectedKeysrequired
Set<string>

Controlled set of selected item IDs.

setSelectedKeysrequired
Dispatch<SetStateAction<Set<string>>>

Setter for the controlled selected keys.

getIsItemSelectable
(item: T) => boolean (default: () => true)

Should this row show a checkbox? Non-selectable rows are excluded from select-all.

getIsItemEnabled
(item: T) => boolean (default: () => true)

Is this row checkbox interactive? Disabled rows are frozen: select-all preserves their state.

Examples

Common configurations, variations, and states.
Table — Row Selection
Open in Playground

Table with row selection checkboxes and a select-all header checkbox.