Install with shadcn
Experimental compatibility. This installs the real Astryx package and creates a local public re-export; it does not copy component implementation source. How compatibility works.
This install URL expires with the draft preview.Install the editable showcase compositionbashnpx shadcn@latest add https://astryx-2z5i6c2u1-fbopensource.vercel.app/r/astryx-component-use-table-selection-state.json
bashnpx shadcn@latest add https://astryx-2z5i6c2u1-fbopensource.vercel.app/r/astryx-example-table-selectable-table.json
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.
tsimport {useTableSelectionState} from '@astryxdesign/core/Table'
Parameters
| Param | Type | Description |
|---|---|---|
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 with row selection checkboxes and a select-all header checkbox.