# Table

Rows and columns of data, such as invoices, members or deploys.

Rows and columns of data: invoices, members, deploys. Two looks. card (default): the records table's look, one quiet surface card, 35px rows, precise rules between rows and columns, text.dense (12.5px) header labels in ink-2 over 13px/500 values in ink; values wrap, nothing is cut. flush: a list of records inside a pane (an issue list, a file list): no card, a hairline between rows only, every row one line (35px), the column marked truncate takes the room left and cuts its free text with a title. While the data loads, placeholder rows and aria-busy. Static parts you compose (header, body, row, head cell, cell, caption), or columns and rows as data. It scrolls sideways when the columns do not fit. The model is records-table, whose blocks (records-table, filter-table, diff-table) could later be built from these parts.

Kind: component · Category: Data · Status: beta · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add table
```

It writes the folder `table/` into the project's ui folder (`index.ts`, `table.tsx`, `Table.vue`, `Table.svelte`, `table.recipe.ts`). First time: [Installation](/installation.md).

## Usage

```tsx
import { Table } from "@/components/ui/table";
```

```vue
import { Table } from "@/components/ui/table";
```

```svelte
import { Table } from "$lib/components/ui/table";
```

## Parts

In the DOM the root carries `data-slot="table"` and each part `data-slot="table-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `div` | `table` |  | The surface card (radius.card, shadow.card) and the sideways scroller: overflow auto, overscroll-x contain (a wheel at an end goes on to the page), thin scrollbar in line-strong. A table wider than the card fades into the surface at the edge it continues past (two sticky 24px veils, each shown while there is more on its side: data-overflow-start and data-overflow-end, kept in step with the scroll position by lib/veil.ts), as the records and filter tables. Its focus ring is drawn inside (keyboard scrolling when the table is wider than the card). flush: no surface, shadow or radius, no veils (nothing to fade into); the scrollbar shows when the columns do not fit. |
| `table` | `table` | `table-table` |  | The <table>: full width, separate borders with no spacing (so the rules are the cells' own), 13px/500 ink, tabular figures. aria-busy="true" while loading. |
| `header` | `thead` | `table-header` |  | The header row group. |
| `body` | `tbody` | `table-body` |  | The body row group. |
| `row` | `tr` | `table-row` |  | One row. In the body its hover fills color.hover at once both ways (gated to a fine pointer), as the records table's rows; the header row does not hover. |
| `head` | `th` | `table-head` |  | A column's header cell: 35px minimum, padding 0 12px, text.dense (12.5px)/500 ink-2, starting at the inline start; a 1px rule (line) under it and at its inline end, none after the last column. Wraps, never cut. flush: no rule at its inline end. truncate: the column takes the room left (width 100%). |
| `cell` | `td` | `table-cell` |  | A value: 35px minimum, padding 6px 12px (header and values share their inline start), 20px lines; the same rules, none under the last row. Wraps whole words (a word longer than the column widens it, and the card scrolls). Author text keeps its own direction while the column keeps the table's alignment. numeric: aligned to the end, tabular figures. flush: one line (nowrap), no rule at its inline end. truncate: takes the room left and cuts its text at the end, with the full text in a title while it is cut (lib/truncate.ts); only for free text (a title), never for a name of a choice or a number. |
| `skeleton` | `span` | `table-skeleton` | optional | A placeholder bar in a loading row (TableSkeleton; the data form draws them): 8px high, pill, hover-2, a varying share of its column (64, 42, 78, 52%), at the end in a number column; aria-hidden. Still: no shimmer across a table. |
| `caption` | `caption` | `table-caption` | optional | The table's name, under the rows inside the card: 12px ink-2, padding 8px 12px, a rule above it. It names the table for assistive technology. |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `columns` | `array` |  | Data form: the columns in order, { key, label, numeric?, truncate? }. With columns and rows the Table renders its own header and body; without them it renders its children (the parts). |
| `rows` | `array` |  | Data form: one object per row, values by column key, shown as text. Rich content (a status pill, an avatar, a link): React, a node as the value; Vue, the cell slot; Svelte, the cell snippet. A row may carry more fields for that slot (a tone, an email). |
| `caption` | `string` |  | Data form: the caption under the rows. With parts, use <TableCaption>. |
| `numeric` | `boolean` | `false` | On TableHead and TableCell: a number column, aligned to the end with tabular figures. |
| `variant` | `"card" \| "flush"` | `"card"` | card: the surface card with rules between rows and columns; values wrap. flush: no card, a hairline between rows only, single-line rows (an issue list in a pane, a file list), the truncate column gives way. |
| `loading` | `boolean` | `false` | The data is on its way: aria-busy on the table; in the data form, loadingRows placeholder rows in place of the rows (the header stays). |
| `loadingRows` | `number` | `5` | How many placeholder rows while loading: as many as the page will most likely show, so the rows do not jump when they arrive. |
| `truncate` | `boolean` | `false` | On TableHead and TableCell (or a column): the column that gives way, cut at the end with a title. One per table, free text only (a title, a message). |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Slots

| Slot | Content |
| --- | --- |
| `default` | The parts: TableHeader, TableBody, TableRow, TableHead, TableCell, TableCaption (when columns and rows are not given). |
| `cell` | Data form: the content of one value cell, inside the cell part (Vue: the cell slot; Svelte: the cell snippet; React: a node as the row's value), called with { row, column, value, rowIndex, columnIndex }. Without it the value is shown as text; render value for the columns left as they are. Not called for loading rows. |

## States

`hover`, `focus-visible`, `loading`

## Keyboard and accessibility

Role: table.

Notes:

- A native <table>: the header cells are <th scope="col">, so a screen reader announces each value with its column.
- The caption names the table; without one, give the root's table an aria-label (pass it on the Table).
- Not interactive: no roving focus. The card itself is reachable by Tab only when it scrolls (the browser makes a scroller focusable), so the keyboard can scroll it.
- While loading the table carries aria-busy="true" and the placeholder bars are aria-hidden; the rows that replace them are announced as the table's content.
- A cut cell carries its full text in title (only while it is cut).

## Motion

- none: rows never animate on sort, load or hover (functional data); the row hover is instant both ways, as in the records table
- edge veils: each shows at once while there is more on its side (data-overflow-start, data-overflow-end, set from the scroll position by lib/veil.ts, the same in every browser; no animation, no time involved); none while the table fits
- loading: the placeholder bars are still (no shimmer, no pulse): a table is a high-frequency surface; the real rows replace them in one frame

## Tokens

`color.surface`, `color.line`, `color.line-strong`, `color.accent`, `color.ink`, `color.ink-2`, `color.hover`, `shadow.card`, `radius.card`, `text.xs`, `text.sm`, `color.hover-2`, `radius.pill`

## Examples

### Recent deploys

React · `recent-deploys.tsx`

```tsx
import { StatusPill } from "@/components/ui/status-pill";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const deploys = [
  { id: "dpl_7f3a9c", branch: "main", status: "Ready", tone: "green", duration: "50s" },
  { id: "dpl_8b21e4", branch: "feat/usage-alerts", status: "Building", tone: "accent", duration: "1m 12s" },
  { id: "dpl_3c90af", branch: "fix/tax-rounding", status: "Failed", tone: "red", duration: "48s" },
] as const;

export default function RecentDeploys() {
  return (
    <Table aria-label="Recent deploys of web-app">
      <TableHeader>
        <TableRow>
          <TableHead>Branch</TableHead>
          <TableHead>Status</TableHead>
          <TableHead numeric>Duration</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {deploys.map((deploy) => (
          <TableRow key={deploy.id}>
            <TableCell>{deploy.branch}</TableCell>
            <TableCell><StatusPill tone={deploy.tone} size="sm">{deploy.status}</StatusPill></TableCell>
            <TableCell numeric>{deploy.duration}</TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}
```

Vue · `recent-deploys.vue`

```vue
<script setup lang="ts">
import { StatusPill } from "@/components/ui/status-pill";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const deploys = [
  { id: "dpl_7f3a9c", branch: "main", status: "Ready", tone: "green", duration: "50s" },
  { id: "dpl_8b21e4", branch: "feat/usage-alerts", status: "Building", tone: "accent", duration: "1m 12s" },
  { id: "dpl_3c90af", branch: "fix/tax-rounding", status: "Failed", tone: "red", duration: "48s" },
] as const;
</script>

<template>
  <Table aria-label="Recent deploys of web-app">
    <TableHeader>
      <TableRow>
        <TableHead>Branch</TableHead>
        <TableHead>Status</TableHead>
        <TableHead numeric>Duration</TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      <TableRow v-for="deploy in deploys" :key="deploy.id">
        <TableCell>{{ deploy.branch }}</TableCell>
        <TableCell><StatusPill :tone="deploy.tone" size="sm">{{ deploy.status }}</StatusPill></TableCell>
        <TableCell numeric>{{ deploy.duration }}</TableCell>
      </TableRow>
    </TableBody>
  </Table>
</template>
```

Svelte · `recent-deploys.svelte`

```svelte
<script lang="ts">
  import { StatusPill } from "$lib/components/ui/status-pill";
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "$lib/components/ui/table";

  const deploys = [
    { id: "dpl_7f3a9c", branch: "main", status: "Ready", tone: "green", duration: "50s" },
    { id: "dpl_8b21e4", branch: "feat/usage-alerts", status: "Building", tone: "accent", duration: "1m 12s" },
    { id: "dpl_3c90af", branch: "fix/tax-rounding", status: "Failed", tone: "red", duration: "48s" },
  ] as const;
</script>

<Table aria-label="Recent deploys of web-app">
  <TableHeader>
    <TableRow>
      <TableHead>Branch</TableHead>
      <TableHead>Status</TableHead>
      <TableHead numeric>Duration</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    {#each deploys as deploy (deploy.id)}
      <TableRow>
        <TableCell>{deploy.branch}</TableCell>
        <TableCell><StatusPill tone={deploy.tone} size="sm">{deploy.status}</StatusPill></TableCell>
        <TableCell numeric>{deploy.duration}</TableCell>
      </TableRow>
    {/each}
  </TableBody>
</Table>
```

### Issue list in a pane (flush)

React · `issue-list.tsx`

```tsx
import { Avatar } from "@/components/ui/avatar";
import { StatusPill } from "@/components/ui/status-pill";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const issues = [
  { id: "NW-482", title: "Add retry to webhook delivery when the endpoint times out", status: "In review", tone: "accent", assignee: "PR", color: "var(--fndn-tag-purple)", updated: "2 min ago" },
  { id: "NW-479", title: "Usage alerts fire twice for the same threshold", status: "In progress", tone: "orange", assignee: "DO", color: "var(--fndn-tag-blue)", updated: "1 h ago" },
  { id: "NW-471", title: "Invoice PDF cuts the tax line", status: "Todo", tone: "neutral", assignee: "AT", color: "var(--fndn-tag-green)", updated: "Nov 14" },
] as const;

/* flush: an issue list inside a pane, one line per row; the title gives way, cut with a title */
export default function IssueList() {
  return (
    <Table variant="flush" aria-label="Open issues in billing-api">
      <TableHeader>
        <TableRow>
          <TableHead>ID</TableHead>
          <TableHead truncate>Title</TableHead>
          <TableHead>Status</TableHead>
          <TableHead>Assignee</TableHead>
          <TableHead numeric>Updated</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {issues.map((issue) => (
          <TableRow key={issue.id}>
            <TableCell className="font-mono text-xs text-ink-2">{issue.id}</TableCell>
            <TableCell truncate>{issue.title}</TableCell>
            <TableCell><StatusPill tone={issue.tone} size="sm">{issue.status}</StatusPill></TableCell>
            <TableCell><Avatar initials={issue.assignee} color={issue.color} size="20" /></TableCell>
            <TableCell numeric className="text-ink-2">{issue.updated}</TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}
```

Vue · `issue-list.vue`

```vue
<script setup lang="ts">
import { Avatar } from "@/components/ui/avatar";
import { StatusPill } from "@/components/ui/status-pill";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const issues = [
  { id: "NW-482", title: "Add retry to webhook delivery when the endpoint times out", status: "In review", tone: "accent", assignee: "PR", color: "var(--fndn-tag-purple)", updated: "2 min ago" },
  { id: "NW-479", title: "Usage alerts fire twice for the same threshold", status: "In progress", tone: "orange", assignee: "DO", color: "var(--fndn-tag-blue)", updated: "1 h ago" },
  { id: "NW-471", title: "Invoice PDF cuts the tax line", status: "Todo", tone: "neutral", assignee: "AT", color: "var(--fndn-tag-green)", updated: "Nov 14" },
] as const;
</script>

<!-- flush: an issue list inside a pane, one line per row; the title gives way, cut with a title -->
<template>
  <Table variant="flush" aria-label="Open issues in billing-api">
    <TableHeader>
      <TableRow>
        <TableHead>ID</TableHead>
        <TableHead truncate>Title</TableHead>
        <TableHead>Status</TableHead>
        <TableHead>Assignee</TableHead>
        <TableHead numeric>Updated</TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      <TableRow v-for="issue in issues" :key="issue.id">
        <TableCell class="font-mono text-xs text-ink-2">{{ issue.id }}</TableCell>
        <TableCell truncate>{{ issue.title }}</TableCell>
        <TableCell><StatusPill :tone="issue.tone" size="sm">{{ issue.status }}</StatusPill></TableCell>
        <TableCell><Avatar :initials="issue.assignee" :color="issue.color" size="20" /></TableCell>
        <TableCell numeric class="text-ink-2">{{ issue.updated }}</TableCell>
      </TableRow>
    </TableBody>
  </Table>
</template>
```

Svelte · `issue-list.svelte`

```svelte
<script lang="ts">
  import { Avatar } from "$lib/components/ui/avatar";
  import { StatusPill } from "$lib/components/ui/status-pill";
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "$lib/components/ui/table";

  const issues = [
    { id: "NW-482", title: "Add retry to webhook delivery when the endpoint times out", status: "In review", tone: "accent", assignee: "PR", color: "var(--fndn-tag-purple)", updated: "2 min ago" },
    { id: "NW-479", title: "Usage alerts fire twice for the same threshold", status: "In progress", tone: "orange", assignee: "DO", color: "var(--fndn-tag-blue)", updated: "1 h ago" },
    { id: "NW-471", title: "Invoice PDF cuts the tax line", status: "Todo", tone: "neutral", assignee: "AT", color: "var(--fndn-tag-green)", updated: "Nov 14" },
  ] as const;
</script>

<!-- flush: an issue list inside a pane, one line per row; the title gives way, cut with a title -->
<Table variant="flush" aria-label="Open issues in billing-api">
  <TableHeader>
    <TableRow>
      <TableHead>ID</TableHead>
      <TableHead truncate>Title</TableHead>
      <TableHead>Status</TableHead>
      <TableHead>Assignee</TableHead>
      <TableHead numeric>Updated</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    {#each issues as issue (issue.id)}
      <TableRow>
        <TableCell class="font-mono text-xs text-ink-2">{issue.id}</TableCell>
        <TableCell truncate>{issue.title}</TableCell>
        <TableCell><StatusPill tone={issue.tone} size="sm">{issue.status}</StatusPill></TableCell>
        <TableCell><Avatar initials={issue.assignee} color={issue.color} size="20" /></TableCell>
        <TableCell numeric class="text-ink-2">{issue.updated}</TableCell>
      </TableRow>
    {/each}
  </TableBody>
</Table>
```

### Invoices with a caption

React · `invoices.tsx`

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

const invoices = [
  { id: "INV-2026-0117", date: "Nov 1, 2026", amount: "$1,240.00" },
  { id: "INV-2026-0104", date: "Oct 1, 2026", amount: "$1,240.00" },
  { id: "INV-2026-0091", date: "Sep 1, 2026", amount: "$980.50" },
];

export default function Invoices() {
  return (
    <Table className="max-w-[440px]">
      <TableCaption>Invoices for Northwind, Team plan</TableCaption>
      <TableHeader>
        <TableRow>
          <TableHead>Invoice</TableHead>
          <TableHead>Date</TableHead>
          <TableHead numeric>Amount</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {invoices.map((invoice) => (
          <TableRow key={invoice.id}>
            <TableCell>{invoice.id}</TableCell>
            <TableCell>{invoice.date}</TableCell>
            <TableCell numeric>{invoice.amount}</TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}
```

Vue · `invoices.vue`

```vue
<script setup lang="ts">
import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const invoices = [
  { id: "INV-2026-0117", date: "Nov 1, 2026", amount: "$1,240.00" },
  { id: "INV-2026-0104", date: "Oct 1, 2026", amount: "$1,240.00" },
  { id: "INV-2026-0091", date: "Sep 1, 2026", amount: "$980.50" },
];
</script>

<template>
  <Table class="max-w-[440px]">
    <TableCaption>Invoices for Northwind, Team plan</TableCaption>
    <TableHeader>
      <TableRow>
        <TableHead>Invoice</TableHead>
        <TableHead>Date</TableHead>
        <TableHead numeric>Amount</TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      <TableRow v-for="invoice in invoices" :key="invoice.id">
        <TableCell>{{ invoice.id }}</TableCell>
        <TableCell>{{ invoice.date }}</TableCell>
        <TableCell numeric>{{ invoice.amount }}</TableCell>
      </TableRow>
    </TableBody>
  </Table>
</template>
```

Svelte · `invoices.svelte`

```svelte
<script lang="ts">
  import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "$lib/components/ui/table";

  const invoices = [
    { id: "INV-2026-0117", date: "Nov 1, 2026", amount: "$1,240.00" },
    { id: "INV-2026-0104", date: "Oct 1, 2026", amount: "$1,240.00" },
    { id: "INV-2026-0091", date: "Sep 1, 2026", amount: "$980.50" },
  ];
</script>

<Table class="max-w-[440px]">
  <TableCaption>Invoices for Northwind, Team plan</TableCaption>
  <TableHeader>
    <TableRow>
      <TableHead>Invoice</TableHead>
      <TableHead>Date</TableHead>
      <TableHead numeric>Amount</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    {#each invoices as invoice (invoice.id)}
      <TableRow>
        <TableCell>{invoice.id}</TableCell>
        <TableCell>{invoice.date}</TableCell>
        <TableCell numeric>{invoice.amount}</TableCell>
      </TableRow>
    {/each}
  </TableBody>
</Table>
```

### Members, from data

React · `members.tsx`

```tsx
import { Table } from "@/components/ui/table";

const columns = [
  { key: "name", label: "Name" },
  { key: "email", label: "Email" },
  { key: "role", label: "Role" },
];

const rows = [
  { name: "Maya Chen", email: "maya@northwind.example", role: "Owner" },
  { name: "Daniel Okafor", email: "daniel@northwind.example", role: "Admin" },
  { name: "Aleksandra Wiśniewska-Kowalczyk", email: "aleksandra.wisniewska@northwind.example", role: "Member" },
  { name: "Jo", email: "jo@northwind.example", role: "Viewer" },
];

export default function Members() {
  return <Table className="max-w-[560px]" aria-label="Members of Northwind" columns={columns} rows={rows} />;
}
```

Vue · `members.vue`

```vue
<script setup lang="ts">
import { Table } from "@/components/ui/table";

const columns = [
  { key: "name", label: "Name" },
  { key: "email", label: "Email" },
  { key: "role", label: "Role" },
];

const rows = [
  { name: "Maya Chen", email: "maya@northwind.example", role: "Owner" },
  { name: "Daniel Okafor", email: "daniel@northwind.example", role: "Admin" },
  { name: "Aleksandra Wiśniewska-Kowalczyk", email: "aleksandra.wisniewska@northwind.example", role: "Member" },
  { name: "Jo", email: "jo@northwind.example", role: "Viewer" },
];
</script>

<template>
  <Table class="max-w-[560px]" aria-label="Members of Northwind" :columns="columns" :rows="rows" />
</template>
```

Svelte · `members.svelte`

```svelte
<script lang="ts">
  import { Table } from "$lib/components/ui/table";

  const columns = [
    { key: "name", label: "Name" },
    { key: "email", label: "Email" },
    { key: "role", label: "Role" },
  ];

  const rows = [
    { name: "Maya Chen", email: "maya@northwind.example", role: "Owner" },
    { name: "Daniel Okafor", email: "daniel@northwind.example", role: "Admin" },
    { name: "Aleksandra Wiśniewska-Kowalczyk", email: "aleksandra.wisniewska@northwind.example", role: "Member" },
    { name: "Jo", email: "jo@northwind.example", role: "Viewer" },
  ];
</script>

<Table class="max-w-[560px]" aria-label="Members of Northwind" {columns} {rows} />
```

### Deploy history, from data with links, pills and avatars

React · `deploy-history.tsx`

```tsx
import { Avatar } from "@/components/ui/avatar";
import { Link } from "@/components/ui/link";
import { StatusPill } from "@/components/ui/status-pill";
import { Table } from "@/components/ui/table";

const columns = [
  { key: "id", label: "Deploy" },
  { key: "branch", label: "Branch" },
  { key: "status", label: "Status" },
  { key: "author", label: "Author" },
  { key: "duration", label: "Duration", numeric: true },
];

const deploys = [
  { id: "dpl_7f3a9c", branch: "main", status: "Ready", tone: "green", author: "Maya Chen", color: "var(--fndn-tag-orange)", duration: "50s" },
  { id: "dpl_8b21e4", branch: "feat/usage-alerts", status: "Building", tone: "accent", author: "Daniel Okafor", color: "var(--fndn-tag-blue)", duration: "1m 12s" },
  { id: "dpl_3c90af", branch: "fix/tax-rounding-on-annual-invoices", status: "Failed", tone: "red", author: "Priya Raman", color: "var(--fndn-tag-purple)", duration: "48s" },
  { id: "dpl_2d77b1", branch: "main", status: "Canceled", tone: "neutral", author: "Jonas Weber", color: "var(--fndn-tag-green)", duration: "6s" },
] as const;

/* the data form with rich cells: a row's value may be a node, for the columns that need more than text */
const rows = deploys.map((d) => ({
  ...d,
  id: <Link href={`/web-app/deploys/${d.id}`} className="font-mono text-xs whitespace-nowrap">{d.id}</Link>,
  status: <StatusPill tone={d.tone} size="sm">{d.status}</StatusPill>,
  author: <span className="inline-flex items-center gap-2 whitespace-nowrap"><Avatar name={d.author} color={d.color} size="20" />{d.author}</span>,
}));

export default function DeployHistory() {
  return <Table aria-label="Deploys of web-app" columns={columns} rows={rows} />;
}
```

Vue · `deploy-history.vue`

```vue
<script setup lang="ts">
import { Avatar } from "@/components/ui/avatar";
import { Link } from "@/components/ui/link";
import { StatusPill } from "@/components/ui/status-pill";
import { Table } from "@/components/ui/table";

const columns = [
  { key: "id", label: "Deploy" },
  { key: "branch", label: "Branch" },
  { key: "status", label: "Status" },
  { key: "author", label: "Author" },
  { key: "duration", label: "Duration", numeric: true },
];

const deploys = [
  { id: "dpl_7f3a9c", branch: "main", status: "Ready", tone: "green", author: "Maya Chen", color: "var(--fndn-tag-orange)", duration: "50s" },
  { id: "dpl_8b21e4", branch: "feat/usage-alerts", status: "Building", tone: "accent", author: "Daniel Okafor", color: "var(--fndn-tag-blue)", duration: "1m 12s" },
  { id: "dpl_3c90af", branch: "fix/tax-rounding-on-annual-invoices", status: "Failed", tone: "red", author: "Priya Raman", color: "var(--fndn-tag-purple)", duration: "48s" },
  { id: "dpl_2d77b1", branch: "main", status: "Canceled", tone: "neutral", author: "Jonas Weber", color: "var(--fndn-tag-green)", duration: "6s" },
] as const;
</script>

<!-- the data form with rich cells: the cell slot renders the columns that need more than text -->
<template>
  <Table aria-label="Deploys of web-app" :columns="columns" :rows="deploys">
    <template #cell="{ row, column, value }">
      <Link v-if="column.key === 'id'" :href="`/web-app/deploys/${row.id}`" class="font-mono text-xs whitespace-nowrap">{{ row.id }}</Link>
      <StatusPill v-else-if="column.key === 'status'" :tone="row.tone" size="sm">{{ row.status }}</StatusPill>
      <span v-else-if="column.key === 'author'" class="inline-flex items-center gap-2 whitespace-nowrap"><Avatar :name="row.author" :color="row.color" size="20" />{{ row.author }}</span>
      <template v-else>{{ value }}</template>
    </template>
  </Table>
</template>
```

Svelte · `deploy-history.svelte`

```svelte
<script lang="ts">
  import { Avatar } from "$lib/components/ui/avatar";
  import { Link } from "$lib/components/ui/link";
  import { StatusPill } from "$lib/components/ui/status-pill";
  import { Table } from "$lib/components/ui/table";

  const columns = [
    { key: "id", label: "Deploy" },
    { key: "branch", label: "Branch" },
    { key: "status", label: "Status" },
    { key: "author", label: "Author" },
    { key: "duration", label: "Duration", numeric: true },
  ];

  const deploys = [
    { id: "dpl_7f3a9c", branch: "main", status: "Ready", tone: "green", author: "Maya Chen", color: "var(--fndn-tag-orange)", duration: "50s" },
    { id: "dpl_8b21e4", branch: "feat/usage-alerts", status: "Building", tone: "accent", author: "Daniel Okafor", color: "var(--fndn-tag-blue)", duration: "1m 12s" },
    { id: "dpl_3c90af", branch: "fix/tax-rounding-on-annual-invoices", status: "Failed", tone: "red", author: "Priya Raman", color: "var(--fndn-tag-purple)", duration: "48s" },
    { id: "dpl_2d77b1", branch: "main", status: "Canceled", tone: "neutral", author: "Jonas Weber", color: "var(--fndn-tag-green)", duration: "6s" },
  ] as const;
</script>

<!-- the data form with rich cells: the cell snippet renders the columns that need more than text -->
<Table aria-label="Deploys of web-app" {columns} rows={deploys}>
  {#snippet cell({ row, column, value })}
    {#if column.key === "id"}
      <Link href="/web-app/deploys/{row.id}" class="font-mono text-xs whitespace-nowrap">{row.id}</Link>
    {:else if column.key === "status"}
      <StatusPill tone={row.tone} size="sm">{row.status}</StatusPill>
    {:else if column.key === "author"}
      <span class="inline-flex items-center gap-2 whitespace-nowrap"><Avatar name={row.author} color={row.color} size="20" />{row.author}</span>
    {:else}
      {value}
    {/if}
  {/snippet}
</Table>
```

### No deploys yet

React · `no-deploys.tsx`

```tsx
import { EmptyState } from "@/components/ui/empty-state";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

/* a table with no rows: one cell across every column holds an empty state */
export default function NoDeploys() {
  return (
    <Table className="max-w-[440px]" aria-label="Deploys of data-pipeline">
      <TableHeader>
        <TableRow>
          <TableHead>Branch</TableHead>
          <TableHead>Status</TableHead>
          <TableHead numeric>Duration</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow>
          <TableCell colSpan={3}>
            <EmptyState size="block" icon="folder-open" title="No deploys yet" hint="Push to main to create the first one." />
          </TableCell>
        </TableRow>
      </TableBody>
    </Table>
  );
}
```

Vue · `no-deploys.vue`

```vue
<script setup lang="ts">
import { EmptyState } from "@/components/ui/empty-state";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
</script>

<!-- a table with no rows: one cell across every column holds an empty state -->
<template>
  <Table class="max-w-[440px]" aria-label="Deploys of data-pipeline">
    <TableHeader>
      <TableRow>
        <TableHead>Branch</TableHead>
        <TableHead>Status</TableHead>
        <TableHead numeric>Duration</TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      <TableRow>
        <TableCell :colspan="3">
          <EmptyState size="block" icon="folder-open" title="No deploys yet" hint="Push to main to create the first one." />
        </TableCell>
      </TableRow>
    </TableBody>
  </Table>
</template>
```

Svelte · `no-deploys.svelte`

```svelte
<script lang="ts">
  import { EmptyState } from "$lib/components/ui/empty-state";
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "$lib/components/ui/table";
</script>

<!-- a table with no rows: one cell across every column holds an empty state -->
<Table class="max-w-[440px]" aria-label="Deploys of data-pipeline">
  <TableHeader>
    <TableRow>
      <TableHead>Branch</TableHead>
      <TableHead>Status</TableHead>
      <TableHead numeric>Duration</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell colspan={3}>
        <EmptyState size="block" icon="folder-open" title="No deploys yet" hint="Push to main to create the first one." />
      </TableCell>
    </TableRow>
  </TableBody>
</Table>
```

### Deploys loading

React · `loading-deploys.tsx`

```tsx
import { Table } from "@/components/ui/table";

const columns = [
  { key: "branch", label: "Branch", truncate: true },
  { key: "status", label: "Status" },
  { key: "duration", label: "Duration", numeric: true },
];

/* while the deploys load: the header and as many still placeholder rows as the page usually shows */
export default function LoadingDeploys() {
  return <Table variant="flush" aria-label="Recent deploys of web-app" columns={columns} rows={[]} loading loadingRows={3} />;
}
```

Vue · `loading-deploys.vue`

```vue
<script setup lang="ts">
import { Table } from "@/components/ui/table";

const columns = [
  { key: "branch", label: "Branch", truncate: true },
  { key: "status", label: "Status" },
  { key: "duration", label: "Duration", numeric: true },
];
</script>

<!-- while the deploys load: the header and as many still placeholder rows as the page usually shows -->
<template>
  <Table variant="flush" aria-label="Recent deploys of web-app" :columns="columns" :rows="[]" loading :loading-rows="3" />
</template>
```

Svelte · `loading-deploys.svelte`

```svelte
<script lang="ts">
  import { Table } from "$lib/components/ui/table";

  const columns = [
    { key: "branch", label: "Branch", truncate: true },
    { key: "status", label: "Status" },
    { key: "duration", label: "Duration", numeric: true },
  ];
</script>

<!-- while the deploys load: the header and as many still placeholder rows as the page usually shows -->
<Table variant="flush" aria-label="Recent deploys of web-app" {columns} rows={[]} loading loadingRows={3} />
```

## Recipe

`table.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";

/* table — a plain data table in the records table's look (records-table.recipe.ts): one quiet surface
 * card, 35px rows, precise rules between rows and columns (the line colour), text-dense/500
 * ink-2 header labels over 13px/500 ink values. Static parts: the root is the card and the sideways
 * scroller, then the <table>, its row groups, rows, head cells, cells and caption.
 *
 * Differences from the records table, on purpose: values wrap instead of being cut (a plain table
 * has no title on its cells and no column menu to widen a column), so a row is 35px at least,
 * not exactly; header labels and values share one inline start (12px in).
 *
 * The rules are the cells' own borders (separate borders, no spacing), so a row's hover fill and
 * the card's radius never fight over a collapsed border. The body row's hover is instant both
 * ways, as the records table's: rows are functional data. No motion; the edge veils of a table
 * wider than its card follow the scroll position (lib/veil.ts), not time. Parts are found by data-slot
 * (table, table-table, table-header, …); the root slot is `base`.
 *
 * flush (variant): a list of records inside a pane (an issue list, a file list, Linear's and
 * GitHub's issue rows): no card (no surface, shadow or radius), no rules between columns, a hairline
 * between rows only, and every cell on one line (nowrap): a row is exactly 35px. The column that
 * gives way is the one marked `truncate` (a title: free text), which takes the room left and is cut
 * at its end with a title (lib/truncate.ts); names of choices and numbers stay whole, and when even
 * they do not fit the table scrolls sideways (no veils in flush: there is no card surface to fade
 * into; the scrollbar shows). The look is carried to the parts by two private properties set on
 * the root (--_col-line, the column rule's colour; --_ws, the cells' white-space), so the static
 * parts need no prop of their own.
 *
 * loading: placeholder rows (`skeleton`, a still bar in hover-2 per cell, its width varying by
 * column) while the data is on its way, aria-busy on the <table>. Still on purpose: a table is a
 * high-frequency surface and a shimmer across every row is noise (the Shimmer is for a label). */

/* the rules shared by head cells and cells: under each, and at the inline end but for the last column */
const GRID_CELL = [
  "border-b border-e border-solid border-b-(color:--_grid-line) border-e-(color:--_col-line,var(--_grid-line))",
  "last:border-e-0 align-middle [unicode-bidi:plaintext] [white-space:var(--_ws,normal)]",
].join(" ");

export const table = tv({
  slots: {
    /* the card scrolls sideways; a wheel at an end goes on to the page. In a flex or grid parent
     * min-w-0 and the scroller keep its width from pushing the parent wider. No inline-size
     * containment: inside a shrink-to-fit parent (a centring stage, a popover) it left the table
     * with no width of its own, 0px and invisible; there it takes its
     * content's width, as any block does */
    base: [
      "relative w-full min-w-0 overflow-x-auto overscroll-x-contain rounded-card bg-surface shadow-card",
      "[--_grid-line:var(--fndn-line)]",
      "[scrollbar-color:var(--fndn-line-strong)_transparent] [scrollbar-width:thin]",
      "focus-visible:outline-2 focus-visible:outline-accent focus-visible:-outline-offset-2",
      /* a table cut by the card's edge fades into the surface on the side it continues past, as the
       * records and filter tables do (a thin or overlay scrollbar is no cue; a mask is ruled out: it
       * would cut the card's shadow). The card is a one-column grid as wide as the table (at least
       * the card), so two sticky veils share the table's area and ride the card's edges. Each shows
       * while there is more on its side, at once (no time involved): data-overflow-start and
       * data-overflow-end, kept in step with the scroll position by watchVeils (lib/veil.ts). A
       * card that fits has neither and shows none. */
      "grid grid-cols-[minmax(min-content,1fr)]",
      "before:content-[''] before:[grid-area:1/1] before:sticky before:z-1 before:w-6 before:pointer-events-none before:opacity-0",
      "after:content-[''] after:[grid-area:1/1] after:sticky after:z-1 after:w-6 after:pointer-events-none after:opacity-0",
      "before:[justify-self:start] before:start-0 before:bg-[linear-gradient(to_var(--_end,right),var(--fndn-surface),transparent)]",
      "after:[justify-self:end] after:end-0 after:bg-[linear-gradient(to_var(--_start,left),var(--fndn-surface),transparent)]",
      "rtl:[--_end:left] rtl:[--_start:right]",
      "data-overflow-start:before:opacity-100 data-overflow-end:after:opacity-100",
    ],
    table: "[grid-area:1/1] w-full border-separate border-spacing-0 text-sm font-medium text-ink tabular-nums",
    header: "",
    body: "",
    /* body rows hover at once both ways; the header row never does */
    row: "[[data-slot=table-body]>&]:hover:bg-hover",
    head: [
      GRID_CELL,
      "h-[35px] px-3 py-1.5 text-dense leading-5 font-medium text-ink-2 wrap-break-word",
    ],
    /* the last row draws no rule under it: the card's edge is the end */
    cell: [
      GRID_CELL,
      "[tr:last-child>&]:border-b-0 h-[35px] px-3 py-1.5 leading-5 wrap-break-word",
    ],
    /* a placeholder bar in a loading row: 8px high, a varying share of its column */
    skeleton: [
      "block h-2 min-w-6 max-w-full rounded-pill bg-hover-2",
      "w-[64%] [td:nth-child(3n+2)>&]:w-[42%] [td:nth-child(3n)>&]:w-[78%] [tr:nth-child(even)>td>&]:w-[52%]",
    ],
    caption: "[caption-side:bottom] px-3 py-2 border-t border-solid border-t-(color:--_grid-line) text-xs leading-normal font-normal text-ink-2 text-start [unicode-bidi:plaintext]",
  },
  variants: {
    /* a number column: values and header at the end, figures aligned. Each value takes its
     * direction from its own text (plaintext) while the column keeps the table's alignment, so the
     * side is physical, by the table's direction (a th ignores match-parent in Chromium) */
    numeric: {
      true: { head: "ltr:text-right rtl:text-left", cell: "ltr:text-right rtl:text-left" },
      false: { head: "ltr:text-left rtl:text-right", cell: "ltr:text-left rtl:text-right" },
    },
    /* the column that gives way: it takes the room left and cuts its free text at the end (the
     * adapters keep a title on a cut cell); in flush every other cell stays whole on one line */
    truncate: {
      true: { head: "w-full", cell: "w-full max-w-0 overflow-hidden text-ellipsis whitespace-nowrap" },
    },
    variant: {
      card: {},
      flush: {
        base: [
          "rounded-none bg-transparent shadow-none [--_col-line:transparent] [--_ws:nowrap]",
          /* no veils without a card surface to fade into */
          "before:hidden after:hidden",
        ],
      },
    },
  },
  compoundVariants: [
    /* a number at the end of a placeholder row sits at the end, as its values will */
    { numeric: true, class: { skeleton: "ms-auto" } },
  ],
  defaultVariants: { numeric: false, variant: "card" },
});

export type TableRecipeProps = VariantProps<typeof table>;
```
