Data tablePro
Sorting, search, filters, selection, bulk actions, column visibility, pagination, expandable rows, export and mobile cards.
| Status | ||||||
|---|---|---|---|---|---|---|
| INV-2026-0900 | Acme Inc. | Paid | Oct 1 | $120 | ||
| INV-2026-0901 | Halcyon | Open | Oct 4 | $3,239 | ||
| INV-2026-0902 | Tessellate | Paid | Oct 7 | $1,558 | ||
| INV-2026-0903 | Solace | Overdue | Oct 10 | $4,677 | ||
| INV-2026-0904 | Northwind | Open | Oct 13 | $2,996 | ||
| INV-2026-0905 | Orbital | Paid | Oct 16 | $1,315 |
- INV-2026-0900
- Customer
- Acme Inc.
- Status
- Paid
- Due
- Oct 1
- Amount
- $120
- INV-2026-0901
- Customer
- Halcyon
- Status
- Open
- Due
- Oct 4
- Amount
- $3,239
- INV-2026-0902
- Customer
- Tessellate
- Status
- Paid
- Due
- Oct 7
- Amount
- $1,558
- INV-2026-0903
- Customer
- Solace
- Status
- Overdue
- Due
- Oct 10
- Amount
- $4,677
- INV-2026-0904
- Customer
- Northwind
- Status
- Open
- Due
- Oct 13
- Amount
- $2,996
- INV-2026-0905
- Customer
- Orbital
- Status
- Paid
- Due
- Oct 16
- Amount
- $1,315
1–6 of 28
1 / 5
When to use
- Records people sort, filter, select and act on: users, invoices, orders.
When not to use
- A few rows with no actions: a plain table is enough.
- Spreadsheet editing.
Installation
Usage
Import it from @/components/ui/data-table after installing.
example.tsx
import { DataTable, type Column } from "@/components/ui/data-table";
type Invoice = { id: string; customer: string; amount: number; status: string };
const columns: Column<Invoice>[] = [
{ key: "customer", header: "Customer", accessor: (r) => r.customer, sortable: true, primary: true },
{ key: "status", header: "Status", accessor: (r) => r.status, filterable: true },
{ key: "amount", header: "Amount", accessor: (r) => r.amount, sortable: true, align: "right", cell: (r) => `$${r.amount}` },
];
export function Invoices({ data }: { data: Invoice[] }) {
return <DataTable data={data} columns={columns} getRowId={(r) => r.id} selectable exportName="invoices" />;
}API reference
DataTable
Sorting, search, filters, selection with bulk actions, column visibility, pagination, expandable rows, CSV export and keyboard navigation. Becomes cards below 640px.
| Prop | Type | Default | Description |
|---|---|---|---|
| data / columns / getRowId | T[] / Column<T>[] / (row) => string | – | Rows, column definitions and a stable id. |
| pageSize | number | 10 | Rows per page. |
| selectable / bulkActions | boolean / { label; icon?; destructive?; onRun(rows) }[] | – | Row checkboxes and actions on the selection. |
| rowActions / renderDetail / onRowClick | (row) => ReactNode | void | – | Last-column actions, expandable detail and row click. |
| exportName | string | – | File name for CSV export. Omit to hide the button. |
| searchPlaceholder / empty / loading | string / ReactNode / boolean | – | Toolbar text, empty state and skeleton rows. |
Column<T>
Describes one column.
| Prop | Type | Default | Description |
|---|---|---|---|
| key / header / accessor | string / string / (row) => string | number | null | – | accessor feeds sorting, search and export. |
| cell | (row) => ReactNode | – | Custom rendering. |
| sortable / filterable / hidden / primary | boolean | – | primary is the card title on phones. |
| align / width | "left" | "right" / string | – | Layout. |
Keyboard interactions
| Keys | Action |
|---|---|
| ↑or↓ | Move between rows |
| Space | Select the focused row |
| Enter | Expand or open the focused row |
| Tab | Reach toolbar and row controls |
Accessibility
- A real <table>; sortable headers set aria-sort.
- Every checkbox and filter is labelled.
- Expandable rows set aria-expanded.
Motion
- Expanded rows animate height; the bulk bar slides up when rows are selected.
Responsive behavior
- Below 640px rows become cards titled by the primary column.
Performance
- Sorting and filtering run in memory; for more than ~5,000 rows, page on the server.
Notes for AI
- accessor must return a primitive; use cell for formatting.
- Keep getRowId stable or selection resets.
This page as Markdown, for assistants and coding agents:
/components/data-table/markdownThe full library index for assistants is at /llms.txt.
Lode222 doc pagesllms.txt