Table
A responsive table. The header and rows are 44px (48px in Large), cells have 12px side padding, and wide tables scroll sideways on small screens.
Installation
npx shadcn@latest add @sevenone/tableUsage
import {
Table,
TableBody,
TableCaption,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"Examples
Invoices
| Invoice | Status | Method | Amount |
|---|---|---|---|
| INV001 | Paid | Credit Card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank Transfer | $350.00 |
| INV004 | Paid | Credit Card | $450.00 |
| INV005 | Paid | PayPal | $550.00 |
| Total | $1,750.00 | ||
<Table>
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead className="w-[100px]">Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow key={invoice.invoice}>
<TableCell className="font-medium">{invoice.invoice}</TableCell>
<TableCell>{invoice.status}</TableCell>
<TableCell>{invoice.method}</TableCell>
<TableCell className="text-right">{invoice.amount}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={3}>Total</TableCell>
<TableCell className="text-right">$1,750.00</TableCell>
</TableRow>
</TableFooter>
</Table>Selection and status
Rows with a checkbox, two lines of text and a status Badge. The checkbox column is 56px wide.
| Customer | Project | Status | Amount | |
|---|---|---|---|---|
Olivia Martin olivia@example.com | Website redesign | $1,999.00 | ||
Liam Johnson liam@example.com | Mobile app | $3,450.00 | ||
Emma Brown emma@example.com | Design system | $2,100.00 |
<TableRow data-state={selected ? "selected" : undefined}>
<TableCell>
<Checkbox aria-label="Select Website redesign" checked={selected} />
</TableCell>
<TableCell>
<div className="font-medium">Olivia Martin</div>
<div className="text-muted-foreground">olivia@example.com</div>
</TableCell>
<TableCell>Website redesign</TableCell>
<TableCell>
<Badge variant="success">Done</Badge>
</TableCell>
<TableCell className="text-right">$1,999.00</TableCell>
</TableRow>Accessibility
- Use TableHead for column titles, so screen readers announce them with each cell.
- Keep the TableCaption: it tells everyone what the table is about.
- Status in a cell is never color alone; the Badge always carries a word.
- Give every row checkbox a label that names the row.