useTableSortable@astryxdesign/core v0.5.2 · useTableSortable
Usage
Call useTableSortable with a config object containing sort state and callback. Pass the returned plugin to Table via the plugins prop.
tsimport {useTableSortable} from '@astryxdesign/core/Table'
Parameters
| Param | Type | Description |
|---|---|---|
sortrequired | Array<{sortKey: TSortKey, direction: 'ascending' | 'descending'}> | Current sort state (TableSortState<TSortKey>). Ordered array of entries; the first is the primary sort, the rest are tiebreakers. An empty array means unsorted. Direction is the full word: 'ascending' / 'descending', not 'asc' / 'desc'. |
onSortChangerequired | (sort: Array<{sortKey: TSortKey, direction: 'ascending' | 'descending'}>) => void | Called when the user clicks a header cell to change sort. Receives the next sort state. |
allowUnsortedState | boolean (default: false) | Allow cycling back to unsorted. When true: 'ascending', 'descending', unsorted. When false: 'ascending', 'descending', 'ascending'. |
isMultiSortEnabled | boolean (default: false) | Enable multi-sort via Shift+click. Regular click still replaces the entire sort state. |
Examples
Common configurations, variations, and states.Table — Sortable Columns
Table with sortable columns, click headers to sort ascending or descending.