Skip to content

Table

A wrapper around React Aria’s Table, TableHeader, Column, TableBody, and Row components. Provides keyboard navigation, sortable columns, and selectable rows.

Terminal window
npx @a2ra/cli add table
{
"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" } }
]
}
}
PropTypeDescription
ariaLabelstringARIA label for the table
columnsTableColumn[]Column definitions (see below)
rowsTableRow[]Row data (see below)
selectionModenone default
single
multiple
Row selection behaviour
selectedKeysstring[]Controlled selected row IDs
defaultSelectedKeysstring[]Uncontrolled default selection
disabledKeysstring[]IDs of non-selectable rows
sortDescriptor{ column: string, direction: string }Current sort state
FieldTypeDescription
idstringColumn identifier (must match keys in row.data)
labelstringColumn heading text
isRowHeaderbooleanWhether this column is the row header
FieldTypeDescription
idstringUnique row identifier
dataRecord<string, string>Cell values keyed by column ID
  • Mark one column as isRowHeader: true so screen readers announce it as the row label.
  • When selectionMode is not "none", a checkbox column is prepended automatically.
  • sortDescriptor is a controlled prop. The agent or parent is responsible for re-ordering rows in response to sort changes.