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.

Source on GitHub

Click a row, sort a column, or select rows.

Deploy a release to see it here.
Plain HTMLclass="ray-table"
Server-renderedNo JavaScript
rayauthUsers list
Code

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).

PropertyAttributeTypeDefaultDescription
columns—arrayColumns: key, label, width, align, sortable, part (an extra part name for its th and td cells), render(row, index), sort(a, b).
data—arrayRows (objects).
rowKeyrow-keystringidField that identifies a row (selection).
selectableselectable reflectsbooleanA checkbox per row and a select-all checkbox.
selection—arrayKeys of the selected rows.
sort—stringCurrent sort; set it, or let header clicks change it.
manualSortmanual-sortbooleanDo not sort here: listen to ray-sort and pass sorted data.
clickableRowsclickable-rows reflectsbooleanRows are focusable and fire ray-row-click (Enter too; arrows move between rows).
stripedstriped reflectsbooleanAlternate row background.
withBorderwith-border reflectsbooleanBorder around the table.
withColumnBorderswith-column-borders reflectsbooleanBorders between columns.
stickyHeadersticky-header reflectsbooleanThe header stays visible while scrolling (with --ray-table-max-height).
noHoverno-hover reflectsbooleanNo row highlight on hover.
densitydensity reflectsxs | sm | md | lgsmCell padding.
labellabelstringCaption (also the table's accessible name).
emptyLabelempty-labelstringNo data (text table.empty)Text without rows (or put a ray-empty-state in slot=empty).
EventDescription
ray-sortA header changed the sort.
ray-selection-changeThe selection changed.
ray-row-clickA row was clicked or activated with Enter (clickable-rows).
SlotDescription
emptyShown instead of the empty text when there are no rows.
PartDescription
tableThe <table>.
scrollThe scroll container.
thEvery header cell (also named by its column's part).
tdEvery body cell (also named by its column's part).

Texts

What it writes itself, in English; setStrings() translates them (Getting started: Languages).

KeyEnglish
table.emptyNo data
table.select-allSelect all rows
table.select-rowSelect row {index}