Data Table
data-tableA typed table with sortable headers, search, row selection with bulk actions and paging. Columns are data and every cell is yours to render. A sticky header, aria-sort, an indeterminate select-all, and a selection that survives sorting.
"use client";
import { Avatar, AvatarFallback, avatarInitials } from "@/components/forme/avatar/avatar";
import { Badge } from "@/components/forme/badge/badge";
import { Button } from "@/components/forme/button/button";
import { DataTable } from "@/components/forme/data-table/data-table";
import type { DataTableColumn } from "@/components/forme/data-table/data-table";
interface Invoice {
id: string;
customer: string;
email: string;
status: "paid" | "pending" | "overdue";
amount: number;
date: string;
}
const invoices: Invoice[] = [
{
id: "INV-2041",
customer: "Acme Inc.",
email: "billing@acme.com",
status: "paid",
amount: 4200,
date: "2026-10-02",
},
{
id: "INV-2040",
customer: "Globex",
email: "ap@globex.io",
status: "pending",
amount: 1280.5,
date: "2026-09-30",
},
{
id: "INV-2039",
customer: "Initech",
email: "finance@initech.co",
status: "overdue",
amount: 860,
date: "2026-09-12",
},
{
id: "INV-2038",
customer: "Umbrella",
email: "pay@umbrella.dev",
status: "paid",
amount: 12450,
date: "2026-09-08",
},
{
id: "INV-2037",
customer: "Hooli",
email: "ar@hooli.com",
status: "paid",
amount: 3100,
date: "2026-09-01",
},
{
id: "INV-2036",
customer: "Stark Industries",
email: "ops@stark.com",
status: "pending",
amount: 7725,
date: "2026-08-27",
},
{
id: "INV-2035",
customer: "Wayne Enterprises",
email: "billing@wayne.co",
status: "paid",
amount: 990,
date: "2026-08-20",
},
{
id: "INV-2034",
customer: "Soylent",
email: "money@soylent.io",
status: "overdue",
amount: 2040,
date: "2026-08-14",
},
];
const money = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" });
const day = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric", timeZone: "UTC" });
const statusVariant = { paid: "success", pending: "warning", overdue: "destructive" } as const;
const columns: DataTableColumn<Invoice>[] = [
{
id: "customer",
header: "Customer",
sortValue: (row) => row.customer,
cell: (row) => (
<div className="flex items-center gap-2.5">
<Avatar size="sm">
<AvatarFallback>{avatarInitials(row.customer)}</AvatarFallback>
</Avatar>
<div className="min-w-0">
<p className="truncate text-body-2-medium">{row.customer}</p>
<p className="truncate text-caption-1-regular text-muted-foreground">{row.id}</p>
</div>
</div>
),
},
{
id: "status",
header: "Status",
sortValue: (row) => row.status,
cell: (row) => (
<Badge size="sm" variant={statusVariant[row.status]} className="capitalize">
{row.status}
</Badge>
),
},
{
id: "date",
header: "Issued",
hideOnMobile: true,
sortValue: (row) => row.date,
cell: (row) => <span className="text-muted-foreground">{day.format(new Date(row.date))}</span>,
},
{
id: "amount",
header: "Amount",
align: "end",
sortValue: (row) => row.amount,
cell: (row) => money.format(row.amount),
},
];
function remindAction() {
return (
<Button size="small" variant="secondary">
Send reminder
</Button>
);
}
export function DataTableDemo() {
return (
<DataTable
className="w-full"
label="Invoices"
rows={invoices}
columns={columns}
getRowId={(row) => row.id}
searchText={(row) => `${row.customer} ${row.email} ${row.id}`}
selectable
selectionActions={remindAction}
pageSize={5}
/>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
Usage
import { DataTable, type DataTableColumn } from "@/components/forme/data-table/data-table";
const columns: DataTableColumn<Invoice>[] = [
{ id: "customer", header: "Customer", cell: (row) => row.customer, sortValue: (row) => row.customer },
{ id: "amount", header: "Amount", cell: (row) => money(row.amount), align: "end" },
];
<DataTable label="Invoices" rows={invoices} columns={columns} getRowId={(row) => row.id} selectable />When to use
Reach for it
- Screens that are mostly a table, where people sort, search, select and page through rows.
Use something else
- Thousands of rows: it sorts and pages on the client. Keep the markup and move the sorting and paging to the server.
- Small read-only lists, where a plain table is simpler.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
DataTable
A table for the screens that are mostly a table: sort, search, select, page.
| Prop | Type | Default | Description |
|---|---|---|---|
rows* | readonly Row[] | — | |
columns* | readonly DataTableColumn<Row>[] | — | |
getRowId* | (row: Row) => string | — | |
label* | string | — | Accessible name for the table. |
selectable | boolean | false | Adds a checkbox column. Selection is reported by id. |
onSelectionChange | (ids: string[]) => void | — | |
selectionActions | (ids: string[]) => ReactNode | — | Rendered in the toolbar while rows are selected — bulk actions go here. |
searchText | (row: Row) => string | — | Adds a search field that matches against this text. |
pageSize | number | — | Rows per page. Omit to show everything. |
empty | ReactNode | "No results." | Shown when there are no rows, or none match the search. |
className | string | — |
Accessibility
- The sorted header carries
aria-sort, and select-all is indeterminate when only some rows are picked. - The selection count is announced as it changes.
Responsive behaviour
- Columns marked
hideOnMobiledrop belowsm, and the search field goes full width. - The header sticks while the body scrolls.
Related


Area Chart
A line or area chart in plain SVG with no chart library. A crosshair snaps to the nearest point and lists every series, arrow keys walk it, round tick values, a legend from two series up, and a hidden table so screen readers get the numbers.
data display

Avatar
A user image with a fallback that shows initials while the image loads, and when it never arrives at all. Built on the Base UI avatar primitive, so the image and the fallback swap without a flash of empty space.
data display

Badge
A small label for status, counts and metadata, in five quiet variants and two sizes. The colour lives in the tint so the text stays readable at eleven pixels, and an icon or a dot inside the badge carries the state at a glance.
data display