Table
A wrapper around React Aria’s Table, TableHeader, Column, TableBody, and Row
components. Provides keyboard navigation, sortable columns, and selectable rows.
Add via CLI
Section titled “Add via CLI”npx @a2ra/cli add tableWith selection
Section titled “With selection”Example JSON
Section titled “Example JSON”{ "type": "Table", "props": { "ariaLabel": "Team members", "selectionMode": "multiple", "columns": [ { "id": "name", "label": "Name", "isRowHeader": true }, { "id": "role", "label": "Role" }, { "id": "joined", "label": "Joined" } ], "rows": [ { "id": "1", "data": { "name": "Alice", "role": "Engineer", "joined": "2023-01" } }, { "id": "2", "data": { "name": "Bob", "role": "Designer", "joined": "2023-06" } } ] }}| Prop | Type | Description |
|---|---|---|
ariaLabel | string | ARIA label for the table |
columns | TableColumn[] | Column definitions (see below) |
rows | TableRow[] | Row data (see below) |
selectionMode | none defaultsinglemultiple | Row selection behaviour |
selectedKeys | string[] | Controlled selected row IDs |
defaultSelectedKeys | string[] | Uncontrolled default selection |
disabledKeys | string[] | IDs of non-selectable rows |
sortDescriptor | { column: string, direction: string } | Current sort state |
TableColumn shape
Section titled “TableColumn shape”| Field | Type | Description |
|---|---|---|
id | string | Column identifier (must match keys in row.data) |
label | string | Column heading text |
isRowHeader | boolean | Whether this column is the row header |
TableRow shape
Section titled “TableRow shape”| Field | Type | Description |
|---|---|---|
id | string | Unique row identifier |
data | Record<string, string> | Cell values keyed by column ID |
- Mark one column as
isRowHeader: trueso screen readers announce it as the row label. - When
selectionModeis not"none", a checkbox column is prepended automatically. sortDescriptoris a controlled prop. The agent or parent is responsible for re-orderingrowsin response to sort changes.