Table
Data grid table primitives matching design system divider and hairline border visual token specifications.
// Plain markup
import { Table, TableBody, TableCell, TableColumnHeaderCell, TableHeader, TableRow } from "@shavin/ui";Basic
Thin styled wrappers over native table elements. Give the column headers scope="col" and right-align numbers so they line up.
| Payee | Account | Due | Amount |
|---|---|---|---|
| City Water & Power | Joint checking | Nov 18 | $84.20 |
| Northside Rentals | Joint checking | Dec 1 | $1,850.00 |
| Bright Steps Daycare | Everyday card | Nov 15 | $640.00 |
import { Table, TableHeader, TableBody, TableRow, TableColumnHeaderCell, TableCell } from "@shavin/ui";
const BILLS = [
{ payee: "City Water & Power", account: "Joint checking", due: "Nov 18", amount: "$84.20" },
{ payee: "Northside Rentals", account: "Joint checking", due: "Dec 1", amount: "$1,850.00" },
{ payee: "Bright Steps Daycare", account: "Everyday card", due: "Nov 15", amount: "$640.00" },
];
export function UpcomingBills() {
return (
<Table>
<TableHeader>
<TableRow>
<TableColumnHeaderCell scope="col">Payee</TableColumnHeaderCell>
<TableColumnHeaderCell scope="col">Account</TableColumnHeaderCell>
<TableColumnHeaderCell scope="col">Due</TableColumnHeaderCell>
<TableColumnHeaderCell scope="col" className="text-right">Amount</TableColumnHeaderCell>
</TableRow>
</TableHeader>
<TableBody>
{BILLS.map((b) => (
<TableRow key={b.payee}>
<TableCell className="font-medium">{b.payee}</TableCell>
<TableCell className="text-fg-muted">{b.account}</TableCell>
<TableCell className="text-fg-muted">{b.due}</TableCell>
<TableCell className="text-right tabular-nums">{b.amount}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
);
}Caption and status
A caption names the table for screen readers; keep it visible or give it the sr-only class. Show status as text or one quiet Badge, not a colour alone.
| Payee | Due | Status | Amount |
|---|---|---|---|
| City Water & Power | Nov 18 | Scheduled | $84.20 |
| Northside Rentals | Dec 1 | Scheduled | $1,850.00 |
| Bright Steps Daycare | Nov 15 | Paid | $640.00 |
| Metro Internet | Nov 21 | Scheduled | $59.99 |
<Table>
<caption className="sr-only">Bills due this month</caption>
<TableHeader>…</TableHeader>
<TableBody>
{BILLS.map((b) => (
<TableRow key={b.payee}>
<TableCell className="font-medium">{b.payee}</TableCell>
<TableCell className="text-fg-muted">{b.due}</TableCell>
<TableCell>
<Badge size="sm" variant={b.status === "Paid" ? "soft" : "outline"}>{b.status}</Badge>
</TableCell>
<TableCell className="text-right tabular-nums">{b.amount}</TableCell>
</TableRow>
))}
</TableBody>
</Table>Rows that open something
TableRow's onClick adds a hover fill, but a row is not focusable, so keyboard users cannot reach it. Put a real link or button in the first cell and let the row click repeat it.
| Date | Payee | Category | Account | Amount |
|---|---|---|---|---|
| Nov 9 | Corner Market | Groceries | Joint checking | −$64.18 |
| Nov 8 | Payroll | Income | Joint checking | +$2,310.00 |
| Nov 7 | Fuel Stop | Transport | Everyday card | −$41.06 |
<TableRow key={t.payee} onClick={() => router.push(t.href)}>
<TableCell className="text-fg-muted">{t.date}</TableCell>
<TableCell className="font-medium">
<Link href={t.href}>{t.payee}</Link>
</TableCell>
…
</TableRow>Parts
| Part | Renders |
|---|---|
| Table | <table> inside a full-width div that scrolls sideways when the table is wider |
| TableHeader | <thead> |
| TableBody | <tbody> with a hairline between rows |
| TableRow | <tr>; with onClick it gets a pointer cursor and hover fill |
| TableColumnHeaderCell | <th>, small uppercase muted text |
| TableCell | <td> |
Table has no sorting, selection or pagination of its own. Every part takes className and the attributes of the element it renders, so scope, colSpan and aria-sort work as usual. For a short list of label and value pairs, use DataList instead.