Skip to content

Data Table

A real table with multi-column sort, search and filters, range selection, column visibility and density, paged or virtualised for thousands of rows.

On this page
Used for
  • Run history
  • Ticket lists
  • Eval results
  • Usage by model
  • Audit logs

Examples

Installation

npx knowns-ui@latest add data-table
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

title / titleAs
ReactNode / "h2" | "h3" | "h4" | "div"
Default - / "h3"
Toolbar title and its tag. Pick the level that follows the page's headings, or div for a name only.
rows / columns / getRowId
T[] / DataColumn<T>[] / (row) => string
Column: { id, header, accessor? (key or fn), cell?, align?, width?, sortable?, compare?, filterable?, searchable?, hideable?, defaultHidden?, label? }. The accessor feeds sort, search and filters.
sort / defaultSort / onSortChange
{ id, desc }[]
Default[]
Header click: ascending → descending → off. Shift-click adds a rule (multi-sort; the rank shows as a small number). Natural order (“Agent 2” before “Agent 10”); empty values last. aria-sort on headers.
selectable / selected / defaultSelected / onSelectedChange
boolean / string[]
Defaultfalse
Checkbox column. Shift-click selects or clears the range from the last clicked row, in display order. The header box selects the shown rows (mixed when some are).
search / filterRow
boolean
Defaulttrue / false
Toolbar search across searchable columns; a row of per-column filter fields under the sticky header.
filterBar / filters / defaultFilters / onFiltersChange
boolean / FilterState
Defaultfalse
A bar of filter chips, one per column with a `variant`. State is one plain object keyed by column id: { kind: "select", values } | { kind: "range", min, max } | { kind: "date", from, to } | { kind: "text", value }. Controlled or not.
column variant / options / formatFilter
"text" | "select" | "range" | "date" / { value, label? }[] / (n) => string
What chip the column gets. A select lists its values with how many rows carry each (counted with the other filters applied), from `options` or from the data. A range is a slider with two number fields; a date is a calendar range.
rowFilter
(row) => boolean
One more rule every row must pass, from your own filter UI. It composes with search, the chips and the filter row.
bulkActions / bulkNoun
({ ids, rows, clear }) => ReactNode / [string, string]
Buttons for the selected rows (needs selectable). The bar rises in with the count and a clear button, Esc clears, and it counts only selected rows still in the filtered list. Also exported alone: DataTableActionBar.
pageSize / pageSizes
number | false / number[]
Default25 / [10, 25, 50, 100]
Paging with a rows-per-page select. false: one scrolling list.
virtualizeAbove / maxHeight
number / px
Default200 / 480
With pageSize false, past this many rows only those in view render, with spacer rows; aria-rowcount and aria-rowindex keep the position known.
density / defaultDensity / onDensityChange
"compact" | "default" | "comfortable"
Default"default"
Row height 32 / 40 / 48. The toolbar switch shows with controls.
controls
boolean
Defaulttrue
Density switch and the Columns menu (switch rows; the last visible column can't be hidden).
loading / empty
boolean / ReactNode
Defaultfalse / -
Skeleton rows with aria-busy; empty text tells “no rows yet” from “no rows match”.
toolbar / title / onRowClick
ReactNode / ReactNode / (row) => void
Extra toolbar content (e.g. bulk actions for the selection); the title names the region and the table.
rowClassName
(row) => string | undefined
Extra classes for one row, for example an enter animation on a row that just arrived.

What it handles

  1. 01Renders a real table element with `aria-sort` on headers, and adds `aria-rowcount` and `aria-rowindex` when the rows are virtualised.
  2. 02Sorts by clicking a header and adds a second rule on Shift-click, using each column's `accessor` or your own `compare` function.
  3. 03Searches every column marked searchable, and filters with `filterBar`: one chip per column with a `variant`, a select that counts rows per value, a number range, a date range or text, or a `filterRow` of fields.
  4. 04Selects rows with a checkbox column when `selectable` is set, Shift-click picks a range, and `bulkActions` adds a bar with the count, your buttons, a clear button and Esc.
  5. 05Pages the rows with `pageSize` and `pageSizes`, or with `pageSize` false it scrolls inside `maxHeight` and only renders the rows in view above `virtualizeAbove`.
  6. 06Switches density between compact, default and roomy, hides columns from a Columns menu, and shows built-in `loading` and `empty` states.

States

First render
Nothing. It paints as it is
none
Row hover
The row background changes colour
120ms, ease out
Selection starts
The action bar fades in and rises 6px
180ms, ease out
Selection clears
The action bar fades out and drops 6px
120ms, ease out
Sort, filter or page change
The rows are replaced at once
none
Loading
Skeleton rows stand in for the body
none
Reduced motion
Nothing extra to stop; the only motion is the colour change
0ms

Works with

When to use

When to use

  • Rows to sort, filter, search, select and page, or thousands of rows with virtualisation.

When not to use

  • A handful of cards or settings: a list reads better: use Card.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Data Table to my app and wire it to my own data.
  • I need rows to sort, filter, search, select and page, or thousands of rows with virtualisation. Set that up with the Knowns UI Data Table.
  • Which Data Table props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "data-table" }) and search_docs({ query: "data table" }).

Need help?

Stuck on Data Table, or found something off? We read every message.