Skip to content
Primitives

Table

Data-readout table with mono cells and uppercase heads.

● LIVE
Sec IDGrid RefStatus
SEC-7F2A12.044, -7.318ONLINE
SEC-3C1908.771, -3.902ARMED
SEC-9B4015.230, -1.677IDLE
SEC-D5E804.918, -9.245ERROR
npx shadcn@latest add https://okibi.cndr.dev/r/table.json

Installation

Install the theme first, then add the component:

npx shadcn@latest add https://okibi.cndr.dev/r/table.json

Copy the source from the Code tab above into components/ui/table.tsx. It uses the cn helper and the okibi theme tokens — install the theme first if you haven't.

Usage

import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

<Table>
  <TableHeader>
    <TableRow>
      <TableHead>Channel</TableHead>
      <TableHead>Status</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>CH-01</TableCell>
      <TableCell>Online</TableCell>
    </TableRow>
  </TableBody>
</Table>

Anatomy

<Table>
  <TableCaption>Channel roster</TableCaption>
  <TableHeader>
    <TableRow>
      <TableHead>Channel</TableHead>
      <TableHead className="text-right">Throughput</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>CH-01</TableCell>
      <TableCell className="text-right tabular-nums">1280</TableCell>
    </TableRow>
  </TableBody>
  <TableFooter>
    <TableRow>
      <TableCell>Total</TableCell>
      <TableCell className="text-right tabular-nums">1280</TableCell>
    </TableRow>
  </TableFooter>
</Table>

Examples

Selection & totals

A data table with a selected row, a right-aligned numeric column, a TableFooter total, and a TableCaption.

● LIVE
Power distribution — kW draw per node.
Bus IDNodeDraw (kW)
PWR-01AReactor Core4,820
PWR-02BShield Array1,375
PWR-03CSensor Grid642
PWR-04DLife Support938
Total7,775

Empty state

Render a single full-width muted row for the empty state.

● LIVE
Sec IDGrid RefStatus
No records

Accessibility

  • Renders native table semantics (table / thead / tbody / tfoot / tr / th / td), so row and column relationships are exposed to assistive tech for free.
  • Use TableCaption to title the table — it renders a native caption that names the grid for screen readers.
  • The scrollable overflow-x-auto container is not keyboard-reachable by default; for wide tables add role='region', tabIndex={0}, and an aria-label so keyboard-only users can scroll it.
  • Selected rows are marked with data-[state=selected]; pair that with an in-row control (e.g. a checkbox) so the selection is operable, not just styled.

Guidelines

Do

  • Right-align numeric columns and add tabular-nums (className='text-right tabular-nums') so figures line up in the mono body.
  • Give every table a TableCaption or an equivalent heading.
  • Use TableFooter for totals — it carries the heavier border-border-strong top rule that reads as a summary row.
  • For long text columns, opt out of the default whitespace-nowrap with whitespace-normal so content wraps instead of forcing horizontal scroll.

Don't

  • Don't use the table for layout — it's a data-readout grid and its semantics are meaningful to AT.
  • Don't leave a wide, scrolling table without a focusable, labeled scroll region.
  • Don't hand-roll header styling — TableHead already supplies the uppercase font-ui heads over the strong rule.

On this page