Data Table
A table with filter, column menu, sorting, row selection and pages, ready to use. 44px controls and rows (48px in Large mode). Built on TanStack Table.
Installation
This component is part of SevenOne Pro.
The Pro license includes the code of every Pro component, the complete Figma file and the Angular version.
Usage
import { DataTable, DataTableSortButton, selectColumn, type ColumnDef } from "@/components/ui/data-table"
const columns: ColumnDef<Payment>[] = [
selectColumn<Payment>(),
{ accessorKey: "status", header: "Status" },
{
accessorKey: "email",
header: ({ column }) => <DataTableSortButton column={column}>Email</DataTableSortButton>,
},
]
<DataTable columns={columns} data={payments} caption="Payments" filterColumn="email" />Examples
Default
Filter by email, sort by email, choose columns, select rows and open the row menu.
| Status | Amount | Actions | ||
|---|---|---|---|---|
| success | ken99@example.com | $316.00 | ||
| success | abe45@example.com | $242.00 | ||
| processing | monserrat44@example.com | $837.00 | ||
| success | silas22@example.com | $874.00 | ||
| failed | carmella@example.com | $721.00 |
0 of 7 row(s) selected.
const columns: ColumnDef<Payment>[] = [
selectColumn<Payment>(),
{
accessorKey: "status",
meta: { label: "Status" },
header: "Status",
cell: ({ row }) => <span className="capitalize">{row.getValue("status")}</span>,
},
{
accessorKey: "email",
meta: { label: "Email" },
header: ({ column }) => <DataTableSortButton column={column}>Email</DataTableSortButton>,
},
{
accessorKey: "amount",
meta: { label: "Amount" },
header: () => <div className="text-right">Amount</div>,
cell: ({ row }) => <div className="text-right font-medium">{usd.format(row.getValue("amount"))}</div>,
},
{
id: "actions",
enableHiding: false,
header: () => <span className="sr-only">Actions</span>,
cell: ({ row }) => (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon">
<span className="sr-only">Open menu for {row.original.email}</span>
<Ellipsis />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>Actions</DropdownMenuLabel>
<DropdownMenuItem>Copy payment ID</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>View customer</DropdownMenuItem>
<DropdownMenuItem>View payment details</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
),
},
]
<DataTable
columns={columns}
data={payments}
caption="Payments"
filterColumn="email"
pageSize={5}
labels={{ filter: "Filter emails..." }}
/>Accessibility
- A real <table> with <th scope="col"> and a hidden caption. The sort control is a button inside the header, and the th exposes aria-sort (WCAG 1.3.1, 4.1.2).
- The "select all" and row checkboxes have labels ("Select all", "Select row"); the selection count is announced politely (WCAG 4.1.3).
- The row menu button has a hidden "Open menu" label; Previous is disabled, not hidden, on the first page.
- Translate every text with the labels prop (filter, Columns, Previous, Next, the count and the page).