DataTable, Pagination

Fiddle
Lists of records with sorting, selection and paging.
docs.acme.devapi.acme.dev
1–2 of 12

Usage

The import, then a use to start from. Both copy as they are.

Import
import { DataTable } from "@/components/ui/data-table/data-table";
Example
<DataTable columns={columns} data={sites} initialPageSize={10}>    <DataTable.Toolbar>        <h3 className="text-subheading">Docs sites</h3>    </DataTable.Toolbar>    <DataTable.Content>        <DataTable.Header />        <DataTable.Body />    </DataTable.Content>    <DataTable.Pagination /></DataTable>

When to use

Use it for

  • Records people sort, filter, select or page through. It's built on TanStack Table: pass columns and data.
  • Client-side by default; manualPagination, manualSorting and pageCount when the server pages the data.
  • DataTable.Pagination pages the table; the standalone Pagination (@/components/ui/pagination) is for lists that aren't tables.
  • Cell values people compare (domains, versions, dates) are set in mono, and a status cell is a StatusBadge.

Avoid

  • A table for a handful of settings: use rows in a Card.
  • A card per record. Rows fit more on a screen.

Accessibility

Checks

  • Row actions are named with their row (“Open docs.acme.dev”), not just “Open”.
  • A clickable row keeps a real link or button inside it, so the keyboard can reach it.

API

Read from each component's stories, the same source as COMPONENTS.md, and kept in step by check:design-system.

DataTable

A composable data table built on top of TanStack Table. Supports client-side and server-side pagination, column filtering, global search, sortable headers, and loading states (skeleton rows on initial load, spinner overlay on subsequent fetches). Composed via sub-components — `DataTable.Toolbar`, `DataTable.Content`, `DataTable.Header`, `DataTable.Body`, `DataTable.Pagination`, and `DataTable.SearchBar` — so the layout is fully flexible.

Its stories don't declare argTypes, so no props are listed. The variants show its states.
VariantsDefaultWithSearchSmallDatasetEmptyServerSidePaginationServerSideWithFetchingServerSideInitialLoadClientSideWithFetchingServerSideControlledSortingWithDividersWithRowClickWithRowClickLeavingModifiedClicksHoverableWithoutClickRowSelectionSelectionActionsFramed

Pagination

No story yet, so its props aren't listed. Read the source, and add a story: it documents the API here and in COMPONENTS.md.

Keep going

Patterns
How components come together into pages.