Data

Table

Structured tabular data. Compose with TableHeader, TableBody, TableRow, TableCell.

Preview
01 Installation

Install

Pull Table from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { Table } from "@brika/clay";
tsxGranular1 line
import { Table } from "@brika/clay/components/table";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxTable.tsx45 lines
import { Badge } from '@brika/clay/components/badge';
import {
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from '@brika/clay/components/table';
const members = [
  { name: 'Alicia Reyes', email: 'alicia@brika.io', role: 'Admin', status: 'Active' },
  { name: 'Tom Hargreaves', email: 'tom@brika.io', role: 'Developer', status: 'Active' },
  { name: 'Yuki Tanaka', email: 'yuki@brika.io', role: 'Designer', status: 'Inactive' },
  { name: 'Dmitri Volkov', email: 'dmitri@brika.io', role: 'Developer', status: 'Active' },
];

/** Full workspace members table with name, email, role, and status columns. */
export default function TableDefaultDemo() {
  return (
    <Table>
      <TableCaption>Workspace members</TableCaption>
      <TableHeader>
        <TableRow>
          <TableHead>Name</TableHead>
          <TableHead>Email</TableHead>
          <TableHead>Role</TableHead>
          <TableHead>Status</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {members.map((m) => (
          <TableRow key={m.email}>
            <TableCell className="font-medium">{m.name}</TableCell>
            <TableCell className="text-muted-foreground">{m.email}</TableCell>
            <TableCell>{m.role}</TableCell>
            <TableCell>
              <Badge variant={m.status === 'Active' ? 'default' : 'outline'}>{m.status}</Badge>
            </TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}
03 Examples

Table, every way

Action

Actions column with Edit and Delete icon buttons per row.

Compact

Dense table using `text-xs` and reduced cell padding, useful for data-heavy views.

Striped

Striped rows using `odd:bg-muted/40` on TableRow, no extra wrapper needed.

04 Accessibility

Accessibility

  • Use <TableCaption> to describe the table, it becomes the accessible name via aria-labelledby.
  • Sortable column headers should carry aria-sort="ascending" or "descending".
  • Action buttons in cells require aria-label that includes the row context (e.g. "Edit Alicia Reyes").
  • The table responds to standard AT table-navigation keys (e.g. Ctrl+Alt+arrows in screen readers).
05 Tokens 4 theme-overridable

Theme tokens

Every CSS variable Table reads, with its default and the dotted path you'd write in a ThemeConfig JSON to override it. Set any of these in your theme to retune Table without touching component code.

Table tokens

4 tokens
ColorFill, border, and text colors.4
  • --table-header-bgcolorvar(--muted)
    components.table.headerBg

    Background for the table footer (and any consumer-defined header rows).

  • --table-row-hover-bgcolorvar(--muted)
    components.table.rowHoverBg

    Background for hovered and selected rows; the hover state applies it at 50% opacity.

  • --table-head-colorcolorvar(--foreground)
    components.table.headColor

    Foreground color of `<TableHead>` cells.

  • --table-caption-colorcolorvar(--muted-foreground)
    components.table.captionColor

    Foreground color of the `<TableCaption>` rendered beneath the table.

Override in a theme

Authoring a theme is plain JSON. Drop overrides under components.table, the names are camelCase versions of the variable suffix.

jsonmy-theme.json12 lines
{
  "id": "my-theme",
  "name": "My Theme",
  "description": "...",
  "accentSwatches": ["#000"],

  "components": {
    "table": {
      "headerBg": "var(--muted)"
    }
  }
}

Then apply with applyTheme(myTheme) (see the theming guide), scope it to a subtree with themeToCssVars(myTheme, mode), or consume any token directly in your own JSX with the matching Tailwind utility (e.g. bg-table-…) — see the chips on each token row.

06 API reference

API reference

Props specific to Table. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.

<Table />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<TableBody />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<TableCaption />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<TableCell />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<TableFooter />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<TableHead />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<TableHeader />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<TableRow />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.