Table
A table with 38px heads and 42px rows, and an embedded variant for tables inside a page.
For rows that are only read. variant="embedded" draws a small table inside a page with a border and taller rows. A table that is wider than its place scrolls sideways inside its own container, which then takes focus so the keyboard can scroll it. For sorting, editing or selection with keyboard movement between cells, use @khaeli/data-grid.
Default
| Release | Channel | Main change | Shipped |
|---|---|---|---|
| 4.2.0 | Stable | Offline drafts | 12 Nov 2026 |
| 4.1.2 | Stable | Faster search | 28 Oct 2026 |
| 4.3.0-beta.1 | Beta | Shared views | 20 Oct 2026 |
| 4.1.1 | Stable | Export to CSV | 6 Oct 2026 |
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
const releases = [
{ version: "4.2.0", channel: "Stable", change: "Offline drafts", shipped: "12 Nov 2026" },
{ version: "4.1.2", channel: "Stable", change: "Faster search", shipped: "28 Oct 2026" },
{ version: "4.3.0-beta.1", channel: "Beta", change: "Shared views", shipped: "20 Oct 2026" },
{ version: "4.1.1", channel: "Stable", change: "Export to CSV", shipped: "6 Oct 2026" },
]
export default function TableDefault() {
return (
<Table aria-label="Releases">
<TableHeader>
<TableRow>
<TableHead>Release</TableHead>
<TableHead>Channel</TableHead>
<TableHead>Main change</TableHead>
<TableHead>Shipped</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{releases.map((release) => (
<TableRow key={release.version}>
<TableCell className="font-medium">{release.version}</TableCell>
<TableCell>{release.channel}</TableCell>
<TableCell>{release.change}</TableCell>
<TableCell>{release.shipped}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
)
}
With caption and footer
| Invoice | Project | Due | Amount |
|---|---|---|---|
| INV-1042 | Atlas redesign | 30 Nov 2026 | €4,800.00 |
| INV-1041 | Billing migration | 24 Nov 2026 | €12,250.00 |
| INV-1040 | Harbor mobile app | 15 Nov 2026 | €7,300.00 |
| Total | €24,350.00 | ||
import {
Table,
TableBody,
TableCaption,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
const invoices = [
{ number: "INV-1042", project: "Atlas redesign", due: "30 Nov 2026", amount: 4800 },
{ number: "INV-1041", project: "Billing migration", due: "24 Nov 2026", amount: 12250 },
{ number: "INV-1040", project: "Harbor mobile app", due: "15 Nov 2026", amount: 7300 },
]
const money = new Intl.NumberFormat("en-GB", { style: "currency", currency: "EUR" })
export default function TableWithCaptionAndFooter() {
return (
<Table aria-labelledby="table-invoices-caption">
<TableCaption id="table-invoices-caption">Invoices issued in November 2026</TableCaption>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Project</TableHead>
<TableHead>Due</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow key={invoice.number}>
<TableCell className="font-medium">{invoice.number}</TableCell>
<TableCell>{invoice.project}</TableCell>
<TableCell>{invoice.due}</TableCell>
<TableCell className="text-right tabular-nums">{money.format(invoice.amount)}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={3}>Total</TableCell>
<TableCell className="text-right tabular-nums">
{money.format(invoices.reduce((sum, invoice) => sum + invoice.amount, 0))}
</TableCell>
</TableRow>
</TableFooter>
</Table>
)
}
Embedded
| Action item | Team | Due |
|---|---|---|
| Confirm the launch date | Product | 21 Nov |
| Review the pricing page copy | Marketing | 24 Nov |
| Migrate the staging database | Platform | 28 Nov |
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
const actions = [
{ task: "Confirm the launch date", owner: "Product", due: "21 Nov" },
{ task: "Review the pricing page copy", owner: "Marketing", due: "24 Nov" },
{ task: "Migrate the staging database", owner: "Platform", due: "28 Nov" },
]
export default function TableEmbedded() {
return (
<Table variant="embedded" aria-label="Action items">
<TableHeader>
<TableRow>
<TableHead>Action item</TableHead>
<TableHead>Team</TableHead>
<TableHead>Due</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{actions.map((action) => (
<TableRow key={action.task}>
<TableCell>{action.task}</TableCell>
<TableCell>{action.owner}</TableCell>
<TableCell>{action.due}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
)
}
Selected rows
| Select | Task | Title | Status |
|---|---|---|---|
| T-318 | Write the migration guide | In review | |
| T-317 | Add keyboard shortcuts to the editor | In progress | |
| T-314 | Fix the export time zone | To do |
"use client"
import { useState } from "react"
import { Checkbox } from "@/components/ui/checkbox"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
const tasks = [
{ id: "T-318", title: "Write the migration guide", status: "In review" },
{ id: "T-317", title: "Add keyboard shortcuts to the editor", status: "In progress" },
{ id: "T-314", title: "Fix the export time zone", status: "To do" },
]
export default function TableSelectedRows() {
const [selected, setSelected] = useState(["T-317"])
return (
<Table aria-label="Tasks">
<TableHeader>
<TableRow>
<TableHead>
<span className="sr-only">Select</span>
</TableHead>
<TableHead>Task</TableHead>
<TableHead>Title</TableHead>
<TableHead>Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{tasks.map((task) => {
const checked = selected.includes(task.id)
return (
<TableRow key={task.id} data-state={checked ? "selected" : undefined}>
<TableCell>
<Checkbox
aria-label={`Select ${task.id}`}
checked={checked}
onCheckedChange={(next) =>
setSelected(next ? [...selected, task.id] : selected.filter((id) => id !== task.id))
}
/>
</TableCell>
<TableCell className="font-medium">{task.id}</TableCell>
<TableCell>{task.title}</TableCell>
<TableCell>{task.status}</TableCell>
</TableRow>
)
})}
</TableBody>
</Table>
)
}
Installation
npx shadcn@latest add @khaeli/tablebunx --bun shadcn@latest add @khaeli/tableInstall @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.
Installs with
- Registry items
Keyboard
Tab- Moves between the controls you put in the cells, such as a checkbox in each row. A table that fits its place takes no focus itself. While it is wider than its place, as on a phone, its scroll container is a tab stop too, with a focus ring inside its edge.
ArrowLeftArrowRight- With focus on the scroll container of a table that is wider than its place, scroll it sideways.
Space- Toggles a focused checkbox in a row.
Accessible name
- Name the table with
aria-labelonTable, or witharia-labelledbypointing at theidof itsTableCaptionwhen a caption is shown. - While the table scrolls sideways, its container is a region with that same name, so a screen reader says what the focused area holds. A table with neither attribute still scrolls from the keyboard, but its container has no name.
TableHeadis ath. A column whose head shows nothing, such as a column of checkboxes, still needs a name: put visually hidden text in it.- A control in a row is named after its row (Select T-318), since the same control repeats on every row.
- A selected row is styled through
data-state="selected". That is for the eye only: the checkbox carries the state.
Registry JSON
The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/table.json