Data table
A table of records on TanStack Table v9 — sort, filters and facets, groups, details, pages, selection, column visibility, pinning and resizing — in the browser or on the server, cards on a phone, windowing for long lists.
- Domain
- Data display
- Support level
- Size
- 39.2 kB gzip
- Who uses it
- 61 files of the live products and sites import it (Verikora: 16, Folioviv: 10, Sovkora: 22, krizaka.com: 1) Counted in the dated inventory of 2026-11-23.
import { DataTable, DataTableFilters, DataTableColumnsMenu, DataTableExport, SelectionBar, useDataTable } from "@krizaka/ui/data-table";Web only — React, from @krizaka/ui/data-table. Beta: its API may still change in a minor version.
- Mobile · n/a. On a phone the rows are a list of cards, each with its fields as a description list — not a table to scroll sideways. → List
Why it is here. Used by Sovkora, Verikora, Folioviv, krizaka.com.
When to use
- To compare records on the same columns: jobs, videos of a studio, users of an admin, invoices, payouts.
- When people sort, filter, group, select several rows for a bulk action, or export what they see.
- In server mode (
manual+onStateChange) when the list lives in a database: the API sorts, filters and pages. - With
virtualizedfor a long list loaded at once (logs, 50,000 events) that must stay smooth.
When not to use
Installation
Install
npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Import
import { DataTable, DataTableFilters, DataTableColumnsMenu, DataTableExport, SelectionBar, useDataTable } from "@krizaka/ui/data-table";Examples
Models catalogue
Eight typed columns that never overflow: priorities move the maker, licence, context and date into the row's detail as the table narrows, then cards under 36 rem.
Invoice list
Title, status and amount always in the row; dates and contact in the detail on a narrow screen; sticky header and zebra rows.
Admin runs
An admin console: filters, columns menu and CSV export in the toolbar, selection, a range filter on the duration, the error in the detail.
Jobs
Sortable columns, a status badge, row selection for a bulk action.
Filters, columns, export
A search, facets with their counts, a range; the filters as chips; hide columns; export the rows shown as CSV.
Server mode
Sort, filters and page go to the API through krizakaFetch and defineKeys of @krizaka/query; the previous page stays while the next one loads.
Bulk actions
selectable + bulkActions: the bar of the selection — the count, the actions the product gives, « Clear selection », and what the last change did (« 2 tagged ») announced politely; sticky, docked above the tab bar on a phone.
Pages
Client pagination under the table, with the rows per page to choose.
Groups
groupBy: a row per group with its count and its total (aggregate), opened to see its rows.
Details
renderDetail: a button per row opens a panel under it.
Pinned and resizable
A wide table: the name pinned at the start, columns resized by drag or by the arrow keys.
Cards on a phone
layout="cards": each row a card, the title on top — what auto does in a narrow container.
List rows on a phone
phone="list": under 36 rem each check is a list row — the selection, the document as the row's link, « Lease · Oct 23 » as one line of facts, the result at the end; a table above.
Applicant files
layout="cards" phone="list": a landlord's files as list rows at every width — the name and unit, the documents and the date as one line, the status.
Loading
Skeleton rows while the first page loads, the table busy.
Empty
No record yet: an empty state with the next step.
Error
The request failed: an alert with a retry, in place of the rows.
50,000 rows
virtualized: only the rows in view are rendered and measured, the header stays.
Props
DataTable
A table of records — sort, filters and facets, groups, details, pages, selection, visibility, pinning, resizing — on the client or the server, cards on a phone, windowing for long lists.
| Prop | Type | Default | Description |
|---|---|---|---|
captionrequired | string | — | What the table lists ("Jobs", "Your videos"): its <caption>, hidden unless showCaption. |
columnsrequired | readonly DataTableColumn<T>[] | — | The columns, in order (stable: module scope or useMemo). |
getRowIdrequired | (row: T) => string | — | A stable id per row: the React key, the selection's value, the expansion's key. |
rowsrequired | readonly T[] | — | The rows (stable: module scope, state or a query's data). Sorted, filtered and paginated here unless manual. |
bulkActions | ((selection: { selected: string[]; clear: () => void; }) => ReactNode) | — | The actions on the selection, given by the product: the bar (SelectionBar) appears under the table while rows are
chosen — the count, these actions, « Clear selection » — sticky, docked above the tab bar on a phone. Needs selectable. |
bulkMax | number | — | The most rows a bulk call takes (200 for @krizaka/organize): the bar says so past it and its actions rest. |
bulkResult | string | — | What the last bulk change did ("3 moved, 1 skipped"), announced politely by the bar. |
className | string | — | Classes merged on the root. |
columnVisibility | Readonly<Record<string, boolean>> | — | Visible (true) or hidden (false) columns, by id (controlled); a column not listed is visible. |
defaultColumnVisibility | Readonly<Record<string, boolean>> | — | The visibility at first, uncontrolled. |
defaultExpanded | Readonly<Record<string, boolean>> | — | The opened rows at first, uncontrolled. |
defaultFilters | Readonly<Record<string, FilterValue>> | — | The filters at first, uncontrolled. |
defaultGroupBy | readonly string[] | — | The grouping at first, uncontrolled. |
defaultPage | number | — | The page at first, uncontrolled. Default 1. |
defaultPageSize | number | — | Rows per page at first, uncontrolled: turns on the pagination under the table. |
defaultSelected | readonly string[] | — | The ids selected at first, uncontrolled. |
defaultSort | DataTableSort | — | The sort at first, uncontrolled. |
density | "compact" | "comfortable" | — | comfortable (default) · compact — one row height per density. |
empty | ReactNode | — | Shown when there is no row (an EmptyState). Default: labels.empty. |
error | ReactNode | — | A failure, shown in place of the rows (an Alert, a retry button); announced. |
expanded | Readonly<Record<string, boolean>> | — | The opened rows and groups (controlled), by id. |
filters | Readonly<Record<string, FilterValue>> | — | The filters in force (controlled), by column id — what DataTableFilters edits. |
footer | ReactNode | — | Under the table (after the pagination): a total, a note. |
getSubRows | ((row: T) => readonly T[]) | — | The children of a row (a tree): each row with children gets a button that shows them. |
groupBy | readonly string[] | — | The columns the rows are grouped by, in order (controlled) — each groupable. |
labels | Partial<DataTableLabels> | — | The words, passed translated; English by default. |
layout | "table" | "auto" | "cards" | — | auto (default): a table, cards below 36rem of container width. table or cards to force one. |
loading | boolean | — | Rows are loading: skeleton rows (loadingRows of them) and aria-busy. |
loadingRows | number | — | How many skeleton rows while loading. Default 5. |
manual | { sorting?: boolean; filtering?: boolean; pagination?: boolean | undefined; } | undefined | — | The server does the work: the rows are shown as given (sorted, filtered, a single page) — fetch in onStateChange. |
onColumnVisibilityChange | ((visibility: Record<string, boolean>) => void) | — | Called with the new visibility (DataTableColumnsMenu). |
onExpandedChange | ((expanded: Record<string, boolean>) => void) | — | Called with the opened rows. |
onFiltersChange | ((filters: Readonly<Record<string, FilterValue>>) => void) | — | Called with the new filters. |
onGroupByChange | ((groupBy: string[]) => void) | — | Called with the new grouping. |
onPageChange | ((page: number) => void) | — | Called with the page asked for. |
onPageSizeChange | ((pageSize: number) => void) | — | Called with the size chosen in the pagination's select (pageSizeOptions). |
onSelectedChange | ((selected: string[]) => void) | — | Called with the new selection. |
onSortChange | ((sort: DataTableSort) => void) | — | Called when a header asks for a new sort. |
onStateChange | ((query: DataTableQuery) => void) | — | Called with the sort, the filters and the page after each change: the query key of a server table. |
page | number | — | The page, from 1 (controlled). |
pageSize | number | — | Rows per page (controlled): turns on the pagination under the table. |
pageSizeOptions | readonly number[] | — | The sizes the pagination offers ([10, 25, 50]). |
phone | "list" | "cards" | cards | What a row becomes on a phone (under 36 rem, or always with layout="cards"): cards (a card per row, its values
labelled) or list — a list row: the selection's checkbox, the title column with its priority: 2 columns joined as
one line of facts, the status / badge column at the end; the other columns in the row's detail. |
pinning | { start?: readonly string[]; end?: readonly string[]; } | undefined | — | Columns that stay in view while the table scrolls sideways: at the start (a name) or the end (actions). |
renderDetail | ((row: T) => ReactNode) | — | A panel under an opened row (the details of a job): each row gets a button that opens it. |
resizing | boolean | — | Columns can be resized (pointer drag, or the arrow keys on the focused handle). |
routeKey | string | — | Keeps the sort, the filters and the page in the address (?clients.sort=…&clients.page=2): back and forward, a reload
and a shared link all land on the same table. Replaces sort, filters and page; needs the router's adapter
(RouteStateProvider) in a framework. |
rowCount | number | — | The number of rows on the server (manual.pagination): the page count and the results' count. |
rowLabel | ((row: T) => string) | — | The name of a row in its labels (checkbox, expand button). Default: its id. |
scroll | boolean | — | The table never scrolls sideways by default once its columns have a type or a priority: what does not fit goes to
the row's detail, then to cards. true opts in to a sideways scroll instead, with fades at the edges. |
selectable | boolean | — | Adds a checkbox per row and one in the header. |
selected | readonly string[] | — | The ids selected (controlled). |
showCaption | boolean | — | Shows the caption above the table. |
sort | DataTableSort | — | The sorted column (controlled), null for none. |
stickyFirstColumn | boolean | — | Keeps the first column in view while the table scrolls sideways (with scroll). |
stickyHeader | number | boolean | — | The header stays at the top of the window while the page scrolls (--dt-top on the table, or a number of px, clears a fixed bar). |
striped | boolean | — | Zebra rows. |
toolbar | ReactNode | — | Above the table, inside its frame: DataTableFilters, DataTableColumnsMenu, DataTableExport, actions. |
virtualized | { height: number; estimateRowHeight?: number; overscan?: number; } | undefined | — | Renders only the rows in view, in a scrolling body of height px; rows are measured (estimateRowHeight is a guess). Forces the table layout. |
SelectionBar
The count, the product's bulk actions, « Clear selection » and the result of the last change — sticky, docked on a phone.
| Prop | Type | Default | Description |
|---|---|---|---|
countrequired | number | — | How many rows are chosen. The bar is not drawn at 0. |
onClearrequired | () => void | — | Clears the selection. |
children | ReactNode | — | The actions the product gives (Buttons). They rest when the selection is over max. |
labels | Partial<SelectionBarLabels> | — | The words, passed translated (English by default). |
max | number | — | The most the service takes at a time (200 for @krizaka/organize): the bar says so past it. |
result | string | — | What the last bulk change did ("3 moved, 1 skipped — 1 has no right to this move"), announced politely. |
DataTableColumnsMenu
A menu of the hideable columns, each a checkbox: the person chooses what the table shows.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Classes merged on the button. |
defaultOpen | boolean | — | Opens the menu at first (a story, a test). |
DataTableExport
Downloads what the table shows — the filtered and sorted rows of every page, the visible columns — as CSV.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Classes merged on the button. |
filename | string | export.csv | The file's name. Default "export.csv". |
onExport | ((csv: string) => void) | — | Receives the CSV instead of downloading it (send it to the server, a test). |
DataTableFilters
The filters of the table, from its columns: a search per text column, a menu of values (with their counts) per
facet column, two bounds per range column; the filters in force as removable chips, "clear all", and the count
of results, announced.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | More controls in the bar (a date range picker, a toggle). |
className | string | — | Classes merged on the bar. |
debounce | number | 250 | The search's wait after the last key, in ms, before the filter applies (a request, in server mode). Default 250. |
Accessibility
- A
tablewith acaption(hidden unlessshowCaption) andscope="col"headers; the roles are written out, so the cards and the list rows keep the table's semantics. - In the list rows the facts are read inside the title's cell (their own cells are hidden at that width, never read twice); the checkbox and the title's link stay in the tab order, above the row's stretched link.
- The sorted column carries
aria-sort; a sortable header is a button that says its state witharia-pressed. - An expand button (a row's details, a group, a tree) says its state with
aria-expandedand names the row; a group's button says its value and its count. - A resize handle is a focusable
separatornamed after its column, with its width asaria-valuenow. - The filters' bar is a named group; the count of results is announced politely when it changes; each filter in force is a chip with a remove button.
- While loading the table is
aria-busyand its caption says so; an error is announced (role="alert"). - Windowed rows carry
aria-rowindexand the tablearia-rowcount: a screen reader knows where it is in the whole list; the scrolling body is a focusable region.
Keyboard
| Keys | Action |
|---|---|
| Tab | Reaches the toolbar, the sort buttons of the headers, the resize handles, the checkboxes, the expand buttons and the links of the cells. |
| Space | Toggles the focused checkbox, sorts by the focused header, or opens the focused row or group. |
| Arrow keys | On a focused resize handle, narrow or widen the column (Shift for larger steps). |
Best practices
- Bulk actions are the product's:
bulkActionsdraws the bar (count, your buttons, « Clear selection »); say what happened inbulkResult(« 3 moved, 1 skipped »), passbulkMaxwhen the service takes a limited number (200), and offer an undo (a toast) after a change that can be undone. - Give the table a
routeKey(routeKey="clients") so its sort, filters and page are in the address: back, reload and a shared link all work. - Keep
rowsandcolumnsstable (module scope, state, a query's data,useMemo): a new array at each render recomputes every model. - Give every column a
header(it labels the value in a card and names its filter) and the row's name acard: "title"column. - Put
DataTableFiltersintoolbar; mark the columns it filters withfilter: "text" | "facet" | "range", and give a server table's facets theiroptions. - Server mode: keep the
DataTableQueryfromonStateChangein state (or the address), put it in the query key, and passrowCount—placeholderData: keepPreviousDatakeeps the page while the next one loads. - Say what failed in
errorwith a way to retry; say what to do next inempty(anEmptyStatewith an action). - Type the columns (
type: title · badge · status · number · date · link · text) and give the secondary ones apriority(2 to 7): the table then never scrolls sideways — columns leave the row for its detail, then the rows become cards. Scrolling is an opt-in (scroll). - A
titlecolumn takes the slack and truncates (full value on hover); badges, statuses, numbers and dates are as wide as their content. Do not give a title column amaxWidth. - A professional list on a phone reads as list rows, not cards:
phone="list"draws each row as the title (give ithref: the whole row is its link), itspriority: 2columns joined as one line of facts, and thestatuscolumn at the end; the other columns go to the row's detail. Keep it to one or two facts. - Align amounts and counts to the end (
align: "end") in tabular numbers; pin the name column of a wide table. - Need something the props do not cover?
useDataTable()gives the TanStack instance — never import@tanstack/*in a product.
Related components
Generated from the code of @krizaka/ui 5.3.4: its meta.ts, its examples and its types.Edit this documentation on GitHub