Table
A data table from columns and data: sorting (aria-sort), row selection, clickable rows, sticky header, striped, empty state. Plain HTML tables: the .ray-table class of base.css.
Click a row, sort a column, or select rows.
| Plain HTML | class="ray-table" |
|---|---|
| Server-rendered | No JavaScript |
| rayauth | Users list |
API
For AI agents: this API as Markdown, or every component in llms-full.txt.
<ray-table> · RayTable
Cells are text (render may return a DOM node; strings are never parsed as HTML). The cells live in the shadow tree, so page CSS does not reach a td: style them with ::part(th), ::part(td) and a column's part (column.part = "mono": ray-table::part(mono) { font-family: var(--ray-font-family-mono) }). The scroll height comes from --ray-table-max-height; the sticky header's background from --ray-table-header-background (default: --ray-surface, which ray-dialog, ray-drawer and ray-card set, else --ray-background); a selected row's from --ray-table-selected-background (default --ray-primary-light; transparent leaves the checkbox alone to show it).
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
columns | — | array | Columns: key, label, width, align, sortable, part (an extra part name for its th and td cells), render(row, index), sort(a, b). | |
data | — | array | Rows (objects). | |
rowKey | row-key | string | id | Field that identifies a row (selection). |
selectable | selectable reflects | boolean | A checkbox per row and a select-all checkbox. | |
selection | — | array | Keys of the selected rows. | |
sort | — | string | Current sort; set it, or let header clicks change it. | |
manualSort | manual-sort | boolean | Do not sort here: listen to ray-sort and pass sorted data. | |
clickableRows | clickable-rows reflects | boolean | Rows are focusable and fire ray-row-click (Enter too; arrows move between rows). | |
striped | striped reflects | boolean | Alternate row background. | |
withBorder | with-border reflects | boolean | Border around the table. | |
withColumnBorders | with-column-borders reflects | boolean | Borders between columns. | |
stickyHeader | sticky-header reflects | boolean | The header stays visible while scrolling (with --ray-table-max-height). | |
noHover | no-hover reflects | boolean | No row highlight on hover. | |
density | density reflects | xs | sm | md | lg | sm | Cell padding. |
label | label | string | Caption (also the table's accessible name). | |
emptyLabel | empty-label | string | No data (text table.empty) | Text without rows (or put a ray-empty-state in slot=empty). |
| Event | Description |
|---|---|
ray-sort | A header changed the sort. |
ray-selection-change | The selection changed. |
ray-row-click | A row was clicked or activated with Enter (clickable-rows). |
| Slot | Description |
|---|---|
empty | Shown instead of the empty text when there are no rows. |
| Part | Description |
|---|---|
table | The <table>. |
scroll | The scroll container. |
th | Every header cell (also named by its column's part). |
td | Every body cell (also named by its column's part). |
Texts
What it writes itself, in English; setStrings() translates them (Getting started: Languages).
| Key | English |
|---|---|
table.empty | No data |
table.select-all | Select all rows |
table.select-row | Select row {index} |