Data Table
Table with search, sorting, column visibility, selection, loading skeletons and two empty states.
Loading documentation…
DataTable is Table with everything a real list needs
bolted on: search, sorting, column visibility, selection with a bulk-action
bar, loading skeletons and two different empty states.
Two layout decisions are worth knowing about.
Filtering and sorting are client-side by default: the 95% case is a page of a few hundred rows you already have, and a server round trip to filter those turns a snappy list into a spinner. Every input is also controllable, so the same component works against a server when the list outgrows the page.
A column is data plus a renderer. cell returns a node, so formatting lives in
the column and not in the rows.
The column you scan for. Full contrast, medium weight.
Tabular figures, right-aligned.
Makes the header a sort button. Return a comparable value, or sort the rows
yourself and pass true to get just the affordance.
Renders in the trailing actions column, revealed on hover.
fixed keeps a column out of the visibility menu; hidden starts it hidden
but still listed.
Three states, and they are not the same thing. loading draws skeleton rows,
empty is "there is nothing here yet", and emptyFiltered is "your query
matched nothing" — a different problem that deserves different words.
Control the query and take over filtering. toolbar is the slot on the right
of the search field — filters, a date range, a "New" button — and footer is
the strip under the table, which is where
Pagination belongs.
The data.
The column definitions.
A stable id per row — selection and React keys both use it.
Adds the search box. Matched against searchFields, or every cell.
The values to match the query against. It defaults to JSON.stringify(row).
Controlled query — pair it with server-side filtering.
Adds the checkbox column and the bulk bar.
Rendered in the bar that replaces the toolbar once something is selected.
The column visibility menu. It defaults to true whenever any column is
toggleable.
The toolbar slot on the right.
A heading above the toolbar.
Skeleton rows instead of data.
Shown when there are no rows at all, and when the query matched nothing.
Makes rows interactive.
Passed through to Table.
The strip under the table — pagination, counts.