Skip to content

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.

PayeeAccountDueAmount
City Water & PowerJoint checkingNov 18$84.20
Northside RentalsJoint checkingDec 1$1,850.00
Bright Steps DaycareEveryday cardNov 15$640.00
Component Source
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.

Bills due this month
PayeeDueStatusAmount
City Water & PowerNov 18Scheduled$84.20
Northside RentalsDec 1Scheduled$1,850.00
Bright Steps DaycareNov 15Paid$640.00
Metro InternetNov 21Scheduled$59.99
Component Source
<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.

DatePayeeCategoryAccountAmount
Nov 9Corner MarketGroceriesJoint checking−$64.18
Nov 8PayrollIncomeJoint checking+$2,310.00
Nov 7Fuel StopTransportEveryday card−$41.06
Component Source
<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

PartRenders
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.

Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font