DataTable
A table with sortable column headers. Click (or Enter/Space) on a header to cycle ascending, descending, then original order. The markup is a plain <table> styled by @stnd/styles, and the sort state is exposed through aria-sort. With manualSort the parent orders rows itself (paginated or server-side lists, where sorting only the visible page would be wrong) and the component only owns the sort state.
accessor?: (row) => any, class?: string }>} [columns] – The columns. A column is sortable unless sortable is false.
a row. Defaults to the row index.
The sort state. Bindable.
spoken for the sort state, for another language.
and the aria-sort markup.
renders. Without it the cell shows row[column.key].
renders.
no rows.
| Type | Name | Description |
|---|---|---|
| object[] | rows? |
The data, one object per row. |
{Array<{ |
key: string, header?: string, sortable?: boolean, numeric?: boolean, | |
| string | ((row) => any) | rowKey? |
A field name, or a function, that identifies |
| { key: string | null, direction: “ascending” | “descending” | “none” | } |
[sort] - |
| string | locale? |
Locale used to compare text. |
| string | caption? |
Accessible caption of the table. |
| any | selectedKey? |
The rowKey of the selected row, marked data-selected. |
| (row) => void | onrowclick? |
Called when a row is clicked. |
| { ascending?: string, descending?: string, none?: string | } |
[labels] – The words |
| boolean | manualSort? |
The parent sorts rows; the component only holds sort |
| string | class? |
Classes on the table. Defaults to “striped”. |
| import(‘svelte’).Snippet<[{ row, column, value | ]>} |
[cell] – Overrides how a cell |
| import(‘svelte’).Snippet<[{ column | ]>} |
[header] – Overrides how a header |
| import(‘svelte’).Snippet | empty? |
Rendered in a full-width row when there are |
<DataTable {rows} columns={[{ key: "name", header: "Name" }, { key: "size", header: "Size", numeric: true }]} rowKey="id" />