# Records Table

A spreadsheet-style table of records with sorting, selection and column menus.

A grid of records such as accounts, contacts or orders, in the spreadsheet manner: one quiet surface, precise rules, colour kept for meaning. Headers sort (aria-sort), rows are selected with a checkbox that takes the place of the row number, a select-all carries the indeterminate state, and each column and row has a menu (the menu component with its own trigger) for sorting, hiding columns and row actions. The first column and the header stay put while both axes scroll. Rows never animate on sort or load; only the selection bar reveals.

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

## Add

```bash
npx fndn add records-table
```

It writes the folder `records-table/` into the project's ui folder (`index.ts`, `records-table.tsx`, `RecordsTable.vue`, `RecordsTable.svelte`, `records-table.recipe.ts`), and what it is built from: [Checkbox](/components/checkbox.md), [Menu](/components/menu.md), [Tooltip](/components/tooltip.md), [Button](/components/button.md), [Tag](/components/tag.md), [Count](/components/count.md), [Empty State](/components/empty-state.md). First time: [Installation](/installation.md).

## Usage

```tsx
import { RecordsTable } from "@/components/ui/records-table";
```

```vue
import { RecordsTable } from "@/components/ui/records-table";
```

```svelte
import { RecordsTable } from "$lib/components/ui/records-table";
```

## Parts

In the DOM the root carries `data-slot="records-table"` and each part `data-slot="records-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` | `records-table` |  | The bordered surface |
| `scroll` | `div` | `records-table-scroll` |  | role=region, focusable; scrolls both ways; at its top or bottom the page scrolls on (sideways overscroll is kept in) |
| `table` | `table` | `records-table-table` |  | table-layout: fixed; min-width is the sum of the visible column widths |
| `head-row` | `tr` | `records-table-head-row` |  |  |
| `th` | `th` | `records-table-th` | repeats | scope=col; aria-sort=ascending\|descending\|none on sortable columns; data-col (the column key). The first column (primary), a number column (numeric) and the trailing menus column (actions) are recipe variants |
| `th-inner` | `div` | `records-table-th-inner` |  |  |
| `sort` | `button` | `records-table-sort` | optional | Sorts by the column (Enter / Space / click) |
| `th-label` | `span` | `records-table-th-label` |  |  |
| `sort-icon` | `span` | `records-table-sort-icon` | optional | Shown while the column is sorted; turns over for descending. kbd-instant |
| `col-menu` | `div` | `records-table-col-menu` | optional | The real Menu, marked data-records-table="col-menu": sort ascending, sort descending, hide column |
| `columns-menu` | `div` | `records-table-columns-menu` | optional | The real Menu in the trailing header cell, marked data-records-table="columns-menu": one checkbox option per hideable column |
| `menu-trigger` | `button` | `records-table-menu-trigger` | repeats | Icon-only trigger of the column, Columns and row menus: the real Button (ghost, xs, square, rounded, muted) with a Tooltip of its name, marked data-menu="trigger" data-records-table="menu-trigger" |
| `row` | `tr` | `records-table-row` | repeats | data-id; selected (its checkbox is on) and openable (onRowOpen given: pointer cursor, focus ring inside its edge, one tab stop for all rows) are recipe variants |
| `cell` | `td` | `records-table-cell` | repeats | data-col; data-value on number and status cells (the sort key). The first column (primary, sticky), a number column (numeric) and the trailing actions cell are recipe variants |
| `primary` | `div` | `records-table-primary` |  | First cell: gutter + value. Sticky at the inline start |
| `gutter` | `span` | `records-table-gutter` |  | Row number at rest; the checkbox takes its place on hover, focus or selection |
| `rownum` | `span` | `records-table-rownum` |  | Position in the displayed order: a CSS counter (::before), so a sort only moves rows; tabular numbers |
| `check` | `label` | `records-table-check` | repeats | The real Checkbox (select all in the header, one per row), marked data-records-table="check" on its root |
| `text` | `span` | `records-table-text` | optional | Truncates at the end; the full value is in title |
| `number` | `span` | `records-table-number` | optional | Tabular numbers, end-aligned, never truncated |
| `tags` | `span` | `records-table-tags` | optional | Up to two tags and a +n; every tag is in title. Tags are the real Tag (tone = one of the eight tag hues, the same for the same word; neutral when the column says tagTone: neutral); +n is a boxed Count |
| `status` | `span` | `records-table-status` | optional | Dot + label; its tone (green\|orange\|red\|accent\|neutral) is a recipe variant |
| `dot` | `span` | `records-table-dot` | optional |  |
| `link` | `a` | `records-table-link` | optional | Opens in a new tab; truncates, full value in title |
| `link-text` | `span` | `records-table-link-text` | optional |  |
| `blank` | `span` | `records-table-blank` | optional | An empty value (—) |
| `row-menu` | `div` | `records-table-row-menu` | optional | One menu popup shared by every row (Zag menu, one trigger per row whose value is the row id), drawn with the menu recipe; its positioner (data-slot="menu-positioner") is marked data-records-table="row-menu" and is portaled |
| `empty-row` | `tr` | `records-table-empty-row` | optional |  |
| `empty` | `td` | `records-table-empty` | optional | Spans every visible column; holds an empty-state block (icon table) that keeps to the visible width of the region |
| `selection` | `div` | `records-table-selection` |  | Reveal region under the table; open while rows are selected (a recipe variant), inert otherwise |
| `selection-inner` | `div` | `records-table-selection-inner` |  |  |
| `selection-count` | `span` | `records-table-selection-count` |  | role=status; tabular numbers |
| `selection-actions` | `div` | `records-table-selection-actions` | optional | The caller's bulk actions, after the count (React: selectionActions, a node or a function of the selected ids; Vue: slot selectionActions with { selected }; Svelte: snippet selectionActions(selected)): Buttons (ghost sm), a Menu. |
| `selection-clear` | `button` | `records-table-selection-clear` |  | The real Button (ghost sm), marked data-records-table="selection-clear" |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `columns` | `{ key: string; label: string; type: text\|number\|tags\|status\|link (default text); sortable: boolean? (default true); hideable: boolean? (default true; the first column never hides); width: number? px; options: { value, label, tone? }[] (status: also the sort order); tagTone: 'hues' \| 'neutral'? tags columns (default hues: each word keeps its own hue, the same in every table). neutral: every tag neutral, for descriptive tags such as a segment or an industry, so colour stays kept for meaning }[]` |  | The first column is the primary one: sticky (never wider than half the region), carries the checkbox, names the row and reads as text. Widths reach the header cells as --fndn-col-width. |
| `rows` | `{ id: string; [column key]: string \| number \| string[] \| null }[]` |  |  |
| `sort` | `object` |  | Bindable (React: `defaultSort` and `onSortChange`; Vue: `v-model:sort`; Svelte: `bind:sort`). { key, direction: ascending\|descending } or null. A header click sorts ascending, a second descending, a third returns to the natural order (null). Blank values sort last either way. |
| `selected` | `array` |  | Bindable (React: `defaultSelected` and `onSelectedChange`; Vue: `v-model:selected`; Svelte: `bind:selected`). Selected row ids. |
| `hiddenColumns` | `array` |  | Bindable (React: `defaultHiddenColumns` and `onHiddenColumnsChange`; Vue: `v-model:hiddenColumns`; Svelte: `bind:hiddenColumns`). Keys of hidden columns. Hidden columns stay in the DOM with the hidden attribute. |
| `rowActions` | `{ value: string; label: string; tone?: 'danger'; disabled?: boolean; type?: 'separator' }[]` |  | Entries of the one menu shared by every row (each row's trigger opens it for that row); no menu without them. |
| `labels` | `object` |  | { region, selectAll, selectRow ({row}), columnMenu ({column}), columns, sortAscending, sortDescending, hideColumn, rowActions ({row}), selected ({count}), clearSelection, empty } |
| `locale` | `string` | `"en-US"` | Locale of the number cells (grouping, decimals). |
| `selectionActions` | `node (children / slot)` |  | Bulk actions in the selection bar, after the count: change status, assign, delete. They receive the selected ids. |

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

## Events

| Event | Payload |
| --- | --- |
| `sortChange` | (sort) |
| `selectedChange` | (selected: string[]) |
| `hiddenColumnsChange` | (hidden: string[]) |
| `rowAction` | (value: string, rowId: string) |
| `rowOpen` | (rowId: string) a click on a row (not on its checkbox, link or menu trigger) or Enter on the focused row; with it the rows are one tab stop (roving tabindex) |

## States

`hover`, `press`, `focus-visible`, `sorted`, `selected`, `indeterminate`, `hidden-column`, `empty`, `openable`

## Keyboard and accessibility

Role: table (region).

Keyboard:

- Tab reaches the scroll region (arrow keys scroll it), then the select-all checkbox, each header's sort button and menu trigger, the Columns menu, and per row its checkbox, link and menu trigger
- Enter / Space on a header sort button sorts by that column: ascending, then descending, then back to the natural order (aria-sort ascending → descending → none)
- Space on a checkbox toggles the row; on select-all it selects every row, or clears them when all are selected
- Column, Columns and row menus follow the menu contract: Enter / Space / ArrowDown open, arrows move, Enter activates, Escape closes and returns focus
- Hiding a column from its own menu moves focus to the Columns menu trigger, where the column can be shown again
- With onRowOpen: the rows are one tab stop (the last focused); ArrowUp / ArrowDown move between rows, Home / End to the first / last, Enter opens the row, Space selects it; Tab from a row goes on to its checkbox, link and menu trigger

Notes:

- The sort state is on the header cell (aria-sort), not in the button name.
- Row checkboxes are named after the primary column (labels.selectRow).
- Truncated text, links and tag lists carry the full value in title.
- The selection count is a role=status region.

## Motion

- rows: no animation on sort, hide or load (functional data); the row hover is instant both ways (a layer over the fill), gated to fine pointers; a selection made under the pointer eases the fill at duration.fast
- gutter: row number and checkbox cross-fade at duration.fast
- sort icon: opacity at duration.fast, turns over at duration.move with easing.out-strong; instant from the keyboard (kbd-instant)
- selection bar: the reveal recipe (grid-template-rows 0fr → 1fr over duration.reveal, opacity over duration.base)
- menus and checkboxes bring their own motion
- edge veil: when columns are cut at the end of the scroll region, that edge fades into the surface; shown at once while there is more past the end (data-overflow-end, set from the scroll position by lib/veil.ts, the same in every browser; no animation, never timed); nothing when the table fits (the start side has the sticky first column and its shadow)

## Tokens

`color.surface`, `color.inset`, `color.hover`, `color.hover-2`, `color.ink`, `color.ink-2`, `color.ink-3`, `color.line`, `color.line-strong`, `color.accent`, `color.accent-ink`, `shadow.card`, `radius.card`, `text.xs`, `text.sm`, `duration.fast`, `duration.base`, `duration.move`, `duration.reveal`, `easing.out-strong`, `color.green`, `color.orange`, `color.red`

## Dependencies

- [Checkbox](/components/checkbox.md)
- [Menu](/components/menu.md)
- [Tooltip](/components/tooltip.md)
- [Button](/components/button.md)
- [Tag](/components/tag.md)
- [Count](/components/count.md)
- [Empty State](/components/empty-state.md)

## Examples

### Customer accounts

React · `default.tsx`

```tsx
import type { ComponentProps } from "react";
import { RecordsTable } from "@/components/ui/records-table";

type Props = ComponentProps<typeof RecordsTable>;

const columns: Props["columns"] = [
  { key: "company", label: "Company", width: 190 },
  { key: "plan", label: "Plan", width: 100 },
  { key: "seats", label: "Seats", type: "number", width: 90 },
  {
    key: "health",
    label: "Health",
    type: "status",
    width: 130,
    options: [
      { value: "at-risk", label: "At risk", tone: "red" },
      { value: "declining", label: "Declining", tone: "orange" },
      { value: "healthy", label: "Healthy", tone: "green" },
      { value: "onboarding", label: "Onboarding", tone: "neutral" },
    ],
  },
];

const rows: Props["rows"] = [
  { id: "brightline", company: "Brightline Dental", plan: "Business", seats: 48, health: "healthy" },
  { id: "kestrel", company: "Kestrel Logistics", plan: "Team", seats: 112, health: "at-risk" },
  { id: "juniper", company: "Juniper Health", plan: "Enterprise", seats: 1240, health: "healthy" },
  { id: "tidewater", company: "Tidewater Realty", plan: "Team", seats: 23, health: "declining" },
  { id: "orbit", company: "Orbit Studio", plan: "Starter", seats: 6, health: "onboarding" },
];

const rowActions: Props["rowActions"] = [
  { value: "open", label: "Open account" },
  { value: "invoices", label: "View invoices" },
  { type: "separator" },
  { value: "cancel", label: "Cancel subscription", tone: "danger" },
];

export default function CustomerAccounts() {
  return (
    <RecordsTable
      columns={columns}
      rows={rows}
      rowActions={rowActions}
      style={{ width: 560 }}
    />
  );
}
```

Vue · `default.vue`

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

const columns = [
  { key: "company", label: "Company", width: 190 },
  { key: "plan", label: "Plan", width: 100 },
  { key: "seats", label: "Seats", type: "number", width: 90 },
  {
    key: "health",
    label: "Health",
    type: "status",
    width: 130,
    options: [
      { value: "at-risk", label: "At risk", tone: "red" },
      { value: "declining", label: "Declining", tone: "orange" },
      { value: "healthy", label: "Healthy", tone: "green" },
      { value: "onboarding", label: "Onboarding", tone: "neutral" },
    ],
  },
] as const;

const rows = [
  { id: "brightline", company: "Brightline Dental", plan: "Business", seats: 48, health: "healthy" },
  { id: "kestrel", company: "Kestrel Logistics", plan: "Team", seats: 112, health: "at-risk" },
  { id: "juniper", company: "Juniper Health", plan: "Enterprise", seats: 1240, health: "healthy" },
  { id: "tidewater", company: "Tidewater Realty", plan: "Team", seats: 23, health: "declining" },
  { id: "orbit", company: "Orbit Studio", plan: "Starter", seats: 6, health: "onboarding" },
];

const rowActions = [
  { value: "open", label: "Open account" },
  { value: "invoices", label: "View invoices" },
  { type: "separator" },
  { value: "cancel", label: "Cancel subscription", tone: "danger" },
] as const;
</script>

<template>
  <RecordsTable :columns="columns" :rows="rows" :rowActions="rowActions" style="width: 560px" />
</template>
```

Svelte · `default.svelte`

```svelte
<script lang="ts">
  import type { ComponentProps } from "svelte";
  import { RecordsTable } from "$lib/components/ui/records-table";

  type Props = ComponentProps<typeof RecordsTable>;

  const columns: Props["columns"] = [
    { key: "company", label: "Company", width: 190 },
    { key: "plan", label: "Plan", width: 100 },
    { key: "seats", label: "Seats", type: "number", width: 90 },
    {
      key: "health",
      label: "Health",
      type: "status",
      width: 130,
      options: [
        { value: "at-risk", label: "At risk", tone: "red" },
        { value: "declining", label: "Declining", tone: "orange" },
        { value: "healthy", label: "Healthy", tone: "green" },
        { value: "onboarding", label: "Onboarding", tone: "neutral" },
      ],
    },
  ];

  const rows = [
    { id: "brightline", company: "Brightline Dental", plan: "Business", seats: 48, health: "healthy" },
    { id: "kestrel", company: "Kestrel Logistics", plan: "Team", seats: 112, health: "at-risk" },
    { id: "juniper", company: "Juniper Health", plan: "Enterprise", seats: 1240, health: "healthy" },
    { id: "tidewater", company: "Tidewater Realty", plan: "Team", seats: 23, health: "declining" },
    { id: "orbit", company: "Orbit Studio", plan: "Starter", seats: 6, health: "onboarding" },
  ];

  const rowActions: Props["rowActions"] = [
    { value: "open", label: "Open account" },
    { value: "invoices", label: "View invoices" },
    { type: "separator" },
    { value: "cancel", label: "Cancel subscription", tone: "danger" },
  ];
</script>

<RecordsTable columns={columns} rows={rows} rowActions={rowActions} style="width: 560px" />
```

### Open an account, act on a selection

React · `open-and-bulk.tsx`

```tsx
import type { ComponentProps } from "react";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { RecordsTable } from "@/components/ui/records-table";

type Props = ComponentProps<typeof RecordsTable>;

const columns: Props["columns"] = [
  { key: "company", label: "Company", width: 190 },
  { key: "plan", label: "Plan", width: 100 },
  { key: "seats", label: "Seats", type: "number", width: 90 },
];

const rows: Props["rows"] = [
  { id: "brightline", company: "Brightline Dental", plan: "Business", seats: 48 },
  { id: "kestrel", company: "Kestrel Logistics", plan: "Team", seats: 112 },
  { id: "juniper", company: "Juniper Health", plan: "Enterprise", seats: 1240 },
];

/* a click (or Enter) on a row opens the account; the checkbox stays its own target, and the
 * selection bar carries what can be done to every selected account */
export default function OpenAndBulk() {
  const [opened, setOpened] = useState<string | null>(null);
  return (
    <div className="flex flex-col gap-2" style={{ width: 400 }}>
      <RecordsTable
        columns={columns}
        rows={rows}
        onRowOpen={setOpened}
        selectionActions={(selected) => (
          <Button variant="ghost" size="sm" onClick={() => setOpened(`${selected.length} exported`)}>Export</Button>
        )}
      />
      <p className="text-sm text-ink-2" role="status">{opened ? `Opened: ${opened}` : "Click a row to open it"}</p>
    </div>
  );
}
```

Vue · `open-and-bulk.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Button } from "@/components/ui/button";
import { RecordsTable } from "@/components/ui/records-table";

const columns = [
  { key: "company", label: "Company", width: 190 },
  { key: "plan", label: "Plan", width: 100 },
  { key: "seats", label: "Seats", type: "number" as const, width: 90 },
];

const rows = [
  { id: "brightline", company: "Brightline Dental", plan: "Business", seats: 48 },
  { id: "kestrel", company: "Kestrel Logistics", plan: "Team", seats: 112 },
  { id: "juniper", company: "Juniper Health", plan: "Enterprise", seats: 1240 },
];

/* a click (or Enter) on a row opens the account; the checkbox stays its own target, and the
 * selection bar carries what can be done to every selected account */
const opened = ref<string | null>(null);
</script>

<template>
  <div class="flex flex-col gap-2" style="width: 400px">
    <RecordsTable :columns="columns" :rows="rows" @row-open="(id: string) => (opened = id)">
      <template #selectionActions="{ selected }">
        <Button variant="ghost" size="sm" @click="opened = `${selected.length} exported`">Export</Button>
      </template>
    </RecordsTable>
    <p class="text-sm text-ink-2" role="status">{{ opened ? `Opened: ${opened}` : "Click a row to open it" }}</p>
  </div>
</template>
```

Svelte · `open-and-bulk.svelte`

```svelte
<script lang="ts">
  import { Button } from "$lib/components/ui/button";
  import { RecordsTable } from "$lib/components/ui/records-table";

  const columns = [
    { key: "company", label: "Company", width: 190 },
    { key: "plan", label: "Plan", width: 100 },
    { key: "seats", label: "Seats", type: "number" as const, width: 90 },
  ];

  const rows = [
    { id: "brightline", company: "Brightline Dental", plan: "Business", seats: 48 },
    { id: "kestrel", company: "Kestrel Logistics", plan: "Team", seats: 112 },
    { id: "juniper", company: "Juniper Health", plan: "Enterprise", seats: 1240 },
  ];

  /* a click (or Enter) on a row opens the account; the checkbox stays its own target, and the
   * selection bar carries what can be done to every selected account */
  let opened = $state<string | null>(null);
</script>

<div class="flex flex-col gap-2" style="width: 400px">
  <RecordsTable {columns} {rows} onrowopen={(id) => (opened = id)}>
    {#snippet selectionActions(selected)}
      <Button variant="ghost" size="sm" onclick={() => (opened = `${selected.length} exported`)}>Export</Button>
    {/snippet}
  </RecordsTable>
  <p class="text-sm text-ink-2" role="status">{opened ? `Opened: ${opened}` : "Click a row to open it"}</p>
</div>
```

### Accounts at risk, picked for outreach

React · `sorted-with-selection.tsx`

```tsx
import type { ComponentProps } from "react";
import { RecordsTable } from "@/components/ui/records-table";

type Props = ComponentProps<typeof RecordsTable>;

const columns: Props["columns"] = [
  { key: "company", label: "Company" },
  { key: "segment", label: "Segment", type: "tags", tagTone: "neutral" },
  { key: "owner", label: "Account owner", width: 150 },
  { key: "active", label: "Last active", sortable: false, width: 140 },
  {
    key: "health",
    label: "Health",
    type: "status",
    width: 140,
    options: [
      { value: "at-risk", label: "At risk", tone: "red" },
      { value: "declining", label: "Declining", tone: "orange" },
      { value: "healthy", label: "Healthy", tone: "green" },
      { value: "onboarding", label: "Onboarding", tone: "neutral" },
    ],
  },
  { key: "mrr", label: "MRR (USD)", type: "number" },
  { key: "website", label: "Website", type: "link", width: 240 },
];

const rows: Props["rows"] = [
  {
    id: "brightline",
    company: "Brightline Dental",
    segment: ["Dental", "Multi-location"],
    owner: "Priya Raman",
    active: "2 hours ago",
    health: "healthy",
    mrr: 4180,
    website: "brightline-dental.example.com",
  },
  {
    id: "kestrel",
    company: "Kestrel Logistics",
    segment: ["Logistics", "Mid-market"],
    owner: "Sofia Alvarez",
    active: "19 days ago",
    health: "at-risk",
    mrr: 12450,
    website: "kestrel-logistics.example.com",
  },
  {
    id: "juniper",
    company: "Juniper Health",
    segment: ["Healthcare", "Enterprise"],
    owner: "Priya Raman",
    active: "Yesterday",
    health: "healthy",
    mrr: 48250,
    website: "juniper-health.example.com",
  },
  {
    id: "saint-aldric",
    company: "Saint Aldric Pediatric Dental Group",
    segment: ["Dental", "Healthcare", "Multi-location"],
    owner: "Priya Raman",
    active: "2 months ago",
    health: "at-risk",
    mrr: 2875,
    website: "saint-aldric-pediatric-dental.example.com",
  },
  {
    id: "tidewater",
    company: "Tidewater Realty",
    segment: ["Real estate", "SMB"],
    owner: "Sofia Alvarez",
    active: "6 weeks ago",
    health: "declining",
    mrr: 1340,
    website: null,
  },
  {
    id: "marlow",
    company: "Marlow Legal Partners",
    segment: ["Legal", "Mid-market"],
    owner: "Sofia Alvarez",
    active: "11 days ago",
    health: "at-risk",
    mrr: 5600,
    website: "marlow-legal.example.com",
  },
  {
    id: "northgate",
    company: "Northgate Physio",
    segment: ["Healthcare", "SMB"],
    owner: "Priya Raman",
    active: "5 days ago",
    health: "healthy",
    mrr: 640,
    website: "northgate-physio.example.com",
  },
  {
    id: "cedar-pine",
    company: "Cedar & Pine Veterinary",
    segment: ["Veterinary"],
    owner: "Priya Raman",
    active: "4 weeks ago",
    health: "declining",
    mrr: 1120,
    website: "cedar-pine-vet.example.com",
  },
  {
    id: "orbit",
    company: "Orbit Studio",
    segment: ["Agency"],
    owner: "Sofia Alvarez",
    active: "3 days ago",
    health: "onboarding",
    mrr: 96,
    website: "orbit-studio.example.com",
  },
  {
    id: "lumen",
    company: "Lumen Fitness Studios",
    segment: ["Fitness", "Multi-location"],
    owner: "Sofia Alvarez",
    active: "Never",
    health: "onboarding",
    mrr: 0,
    website: null,
  },
];

const rowActions: Props["rowActions"] = [
  { value: "open", label: "Open account" },
  { value: "email", label: "Email account owner" },
  { value: "invoices", label: "View invoices" },
  { type: "separator" },
  { value: "cancel", label: "Cancel subscription", tone: "danger" },
];

export default function AtRiskOutreach() {
  return (
    <RecordsTable
      columns={columns}
      rows={rows}
      rowActions={rowActions}
      defaultSort={{ key: "health", direction: "ascending" }}
      defaultSelected={["kestrel", "saint-aldric", "marlow"]}
      style={{ width: 760 }}
    />
  );
}
```

Vue · `sorted-with-selection.vue`

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

const columns = [
  { key: "company", label: "Company" },
  { key: "segment", label: "Segment", type: "tags", tagTone: "neutral" },
  { key: "owner", label: "Account owner", width: 150 },
  { key: "active", label: "Last active", sortable: false, width: 140 },
  {
    key: "health",
    label: "Health",
    type: "status",
    width: 140,
    options: [
      { value: "at-risk", label: "At risk", tone: "red" },
      { value: "declining", label: "Declining", tone: "orange" },
      { value: "healthy", label: "Healthy", tone: "green" },
      { value: "onboarding", label: "Onboarding", tone: "neutral" },
    ],
  },
  { key: "mrr", label: "MRR (USD)", type: "number" },
  { key: "website", label: "Website", type: "link", width: 240 },
] as const;

const rows = [
  {
    id: "brightline",
    company: "Brightline Dental",
    segment: ["Dental", "Multi-location"],
    owner: "Priya Raman",
    active: "2 hours ago",
    health: "healthy",
    mrr: 4180,
    website: "brightline-dental.example.com",
  },
  {
    id: "kestrel",
    company: "Kestrel Logistics",
    segment: ["Logistics", "Mid-market"],
    owner: "Sofia Alvarez",
    active: "19 days ago",
    health: "at-risk",
    mrr: 12450,
    website: "kestrel-logistics.example.com",
  },
  {
    id: "juniper",
    company: "Juniper Health",
    segment: ["Healthcare", "Enterprise"],
    owner: "Priya Raman",
    active: "Yesterday",
    health: "healthy",
    mrr: 48250,
    website: "juniper-health.example.com",
  },
  {
    id: "saint-aldric",
    company: "Saint Aldric Pediatric Dental Group",
    segment: ["Dental", "Healthcare", "Multi-location"],
    owner: "Priya Raman",
    active: "2 months ago",
    health: "at-risk",
    mrr: 2875,
    website: "saint-aldric-pediatric-dental.example.com",
  },
  {
    id: "tidewater",
    company: "Tidewater Realty",
    segment: ["Real estate", "SMB"],
    owner: "Sofia Alvarez",
    active: "6 weeks ago",
    health: "declining",
    mrr: 1340,
    website: null,
  },
  {
    id: "marlow",
    company: "Marlow Legal Partners",
    segment: ["Legal", "Mid-market"],
    owner: "Sofia Alvarez",
    active: "11 days ago",
    health: "at-risk",
    mrr: 5600,
    website: "marlow-legal.example.com",
  },
  {
    id: "northgate",
    company: "Northgate Physio",
    segment: ["Healthcare", "SMB"],
    owner: "Priya Raman",
    active: "5 days ago",
    health: "healthy",
    mrr: 640,
    website: "northgate-physio.example.com",
  },
  {
    id: "cedar-pine",
    company: "Cedar & Pine Veterinary",
    segment: ["Veterinary"],
    owner: "Priya Raman",
    active: "4 weeks ago",
    health: "declining",
    mrr: 1120,
    website: "cedar-pine-vet.example.com",
  },
  {
    id: "orbit",
    company: "Orbit Studio",
    segment: ["Agency"],
    owner: "Sofia Alvarez",
    active: "3 days ago",
    health: "onboarding",
    mrr: 96,
    website: "orbit-studio.example.com",
  },
  {
    id: "lumen",
    company: "Lumen Fitness Studios",
    segment: ["Fitness", "Multi-location"],
    owner: "Sofia Alvarez",
    active: "Never",
    health: "onboarding",
    mrr: 0,
    website: null,
  },
];

const rowActions = [
  { value: "open", label: "Open account" },
  { value: "email", label: "Email account owner" },
  { value: "invoices", label: "View invoices" },
  { type: "separator" },
  { value: "cancel", label: "Cancel subscription", tone: "danger" },
] as const;

const sort = ref({ key: "health", direction: "ascending" as const });

const selected = ref(["kestrel", "saint-aldric", "marlow"]);
</script>

<template>
  <RecordsTable
    :columns="columns"
    :rows="rows"
    :rowActions="rowActions"
    v-model:sort="sort"
    v-model:selected="selected"
    style="width: 760px"
  />
</template>
```

Svelte · `sorted-with-selection.svelte`

```svelte
<script lang="ts">
  import type { ComponentProps } from "svelte";
  import { RecordsTable } from "$lib/components/ui/records-table";

  type Props = ComponentProps<typeof RecordsTable>;

  const columns: Props["columns"] = [
    { key: "company", label: "Company" },
    { key: "segment", label: "Segment", type: "tags", tagTone: "neutral" },
    { key: "owner", label: "Account owner", width: 150 },
    { key: "active", label: "Last active", sortable: false, width: 140 },
    {
      key: "health",
      label: "Health",
      type: "status",
      width: 140,
      options: [
        { value: "at-risk", label: "At risk", tone: "red" },
        { value: "declining", label: "Declining", tone: "orange" },
        { value: "healthy", label: "Healthy", tone: "green" },
        { value: "onboarding", label: "Onboarding", tone: "neutral" },
      ],
    },
    { key: "mrr", label: "MRR (USD)", type: "number" },
    { key: "website", label: "Website", type: "link", width: 240 },
  ];

  const rows = [
    {
      id: "brightline",
      company: "Brightline Dental",
      segment: ["Dental", "Multi-location"],
      owner: "Priya Raman",
      active: "2 hours ago",
      health: "healthy",
      mrr: 4180,
      website: "brightline-dental.example.com",
    },
    {
      id: "kestrel",
      company: "Kestrel Logistics",
      segment: ["Logistics", "Mid-market"],
      owner: "Sofia Alvarez",
      active: "19 days ago",
      health: "at-risk",
      mrr: 12450,
      website: "kestrel-logistics.example.com",
    },
    {
      id: "juniper",
      company: "Juniper Health",
      segment: ["Healthcare", "Enterprise"],
      owner: "Priya Raman",
      active: "Yesterday",
      health: "healthy",
      mrr: 48250,
      website: "juniper-health.example.com",
    },
    {
      id: "saint-aldric",
      company: "Saint Aldric Pediatric Dental Group",
      segment: ["Dental", "Healthcare", "Multi-location"],
      owner: "Priya Raman",
      active: "2 months ago",
      health: "at-risk",
      mrr: 2875,
      website: "saint-aldric-pediatric-dental.example.com",
    },
    {
      id: "tidewater",
      company: "Tidewater Realty",
      segment: ["Real estate", "SMB"],
      owner: "Sofia Alvarez",
      active: "6 weeks ago",
      health: "declining",
      mrr: 1340,
      website: null,
    },
    {
      id: "marlow",
      company: "Marlow Legal Partners",
      segment: ["Legal", "Mid-market"],
      owner: "Sofia Alvarez",
      active: "11 days ago",
      health: "at-risk",
      mrr: 5600,
      website: "marlow-legal.example.com",
    },
    {
      id: "northgate",
      company: "Northgate Physio",
      segment: ["Healthcare", "SMB"],
      owner: "Priya Raman",
      active: "5 days ago",
      health: "healthy",
      mrr: 640,
      website: "northgate-physio.example.com",
    },
    {
      id: "cedar-pine",
      company: "Cedar & Pine Veterinary",
      segment: ["Veterinary"],
      owner: "Priya Raman",
      active: "4 weeks ago",
      health: "declining",
      mrr: 1120,
      website: "cedar-pine-vet.example.com",
    },
    {
      id: "orbit",
      company: "Orbit Studio",
      segment: ["Agency"],
      owner: "Sofia Alvarez",
      active: "3 days ago",
      health: "onboarding",
      mrr: 96,
      website: "orbit-studio.example.com",
    },
    {
      id: "lumen",
      company: "Lumen Fitness Studios",
      segment: ["Fitness", "Multi-location"],
      owner: "Sofia Alvarez",
      active: "Never",
      health: "onboarding",
      mrr: 0,
      website: null,
    },
  ];

  const rowActions: Props["rowActions"] = [
    { value: "open", label: "Open account" },
    { value: "email", label: "Email account owner" },
    { value: "invoices", label: "View invoices" },
    { type: "separator" },
    { value: "cancel", label: "Cancel subscription", tone: "danger" },
  ];

  let sort = $state<Props["sort"]>({ key: "health", direction: "ascending" });

  let selected = $state(["kestrel", "saint-aldric", "marlow"]);
</script>

<RecordsTable
  columns={columns}
  rows={rows}
  rowActions={rowActions}
  bind:sort={sort}
  bind:selected={selected}
  style="width: 760px"
/>
```

### No accounts at risk

React · `empty.tsx`

```tsx
import type { ComponentProps } from "react";
import { RecordsTable } from "@/components/ui/records-table";

type Props = ComponentProps<typeof RecordsTable>;

const columns: Props["columns"] = [
  { key: "company", label: "Company", width: 190 },
  { key: "plan", label: "Plan", width: 100 },
  { key: "seats", label: "Seats", type: "number", width: 90 },
  {
    key: "health",
    label: "Health",
    type: "status",
    width: 130,
    options: [
      { value: "at-risk", label: "At risk", tone: "red" },
      { value: "declining", label: "Declining", tone: "orange" },
      { value: "healthy", label: "Healthy", tone: "green" },
      { value: "onboarding", label: "Onboarding", tone: "neutral" },
    ],
  },
];

const labels: Props["labels"] = { empty: "No accounts at risk this week" };

export default function NoAccountsAtRisk() {
  return <RecordsTable columns={columns} rows={[]} labels={labels} style={{ width: 560 }} />;
}
```

Vue · `empty.vue`

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

const columns = [
  { key: "company", label: "Company", width: 190 },
  { key: "plan", label: "Plan", width: 100 },
  { key: "seats", label: "Seats", type: "number", width: 90 },
  {
    key: "health",
    label: "Health",
    type: "status",
    width: 130,
    options: [
      { value: "at-risk", label: "At risk", tone: "red" },
      { value: "declining", label: "Declining", tone: "orange" },
      { value: "healthy", label: "Healthy", tone: "green" },
      { value: "onboarding", label: "Onboarding", tone: "neutral" },
    ],
  },
] as const;

const labels = { empty: "No accounts at risk this week" };
</script>

<template>
  <RecordsTable :columns="columns" :rows="[]" :labels="labels" style="width: 560px" />
</template>
```

Svelte · `empty.svelte`

```svelte
<script lang="ts">
  import type { ComponentProps } from "svelte";
  import { RecordsTable } from "$lib/components/ui/records-table";

  type Props = ComponentProps<typeof RecordsTable>;

  const columns: Props["columns"] = [
    { key: "company", label: "Company", width: 190 },
    { key: "plan", label: "Plan", width: 100 },
    { key: "seats", label: "Seats", type: "number", width: 90 },
    {
      key: "health",
      label: "Health",
      type: "status",
      width: 130,
      options: [
        { value: "at-risk", label: "At risk", tone: "red" },
        { value: "declining", label: "Declining", tone: "orange" },
        { value: "healthy", label: "Healthy", tone: "green" },
        { value: "onboarding", label: "Onboarding", tone: "neutral" },
      ],
    },
  ];

  const labels = { empty: "No accounts at risk this week" };
</script>

<RecordsTable columns={columns} rows={[]} labels={labels} style="width: 560px" />
```

## Recipe

`records-table.recipe.ts`:

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

/* records-table — a records grid in the spreadsheet manner: one quiet surface, precise rules,
 * colour kept for meaning. The header and the first column stay put while both axes scroll.
 * Rows never animate on sort, hide or load (functional data); hover is colour only and gated.
 * Row numbers are a CSS counter, so a sort only moves rows and never rewrites them.
 *
 * Composed parts, rendered by the adapter: tags are the real Tag, "+N" is a boxed Count, the
 * column, Columns and row menu triggers are Buttons (ghost, xs, square, rounded, muted) with
 * Tooltips, restyled by the menu-trigger slot (its `trigger` variant says which; marked data-menu="trigger" and data-records-table="menu-trigger"); the column and
 * Columns menus are Menus whose root takes the col-menu / columns-menu slot; the shared row menu
 * is drawn with the menu recipe; the checkboxes are Checkboxes (the check slot); the empty table
 * is an EmptyState; Clear selection is a Button (the selection-clear slot).
 *
 * Row state reaches the cells through inherited properties set on the row (--_cell-bg), and the
 * header's and the row's hover through the named groups rt-th and rt-row (only these parts carry
 * them, so nothing nested can match). The row hover is instant both ways (--_cell-hover, a layer over
 * the fill); only a selection under the pointer eases the fill: a
 * select-all or a sort changes hundreds of cells at once, and a transition on each of them costs
 * more than the whole repaint. */

/* the rules shared by header and body cells */
const GRID_CELL = "p-0 border-e border-b border-e-(color:--_grid-line) border-b-(color:--_grid-line) text-start align-middle";
/* sticky first column's soft edge */
const EDGE = "shadow-[5px_0_8px_-10px_oklch(0_0_0/0.4)] rtl:shadow-[-5px_0_8px_-10px_oklch(0_0_0/0.4)]";
/* one line, cut at the end; each value takes its direction from its own text while the column
 * keeps the table's alignment */
const TRUNCATE = "min-w-0 overflow-hidden text-ellipsis whitespace-nowrap [unicode-bidi:plaintext] [text-align:match-parent]";
/* a row control revealed by the row under the pointer, keyboard focus, or a touch screen */
const ON_TOUCH = "pointer-coarse:opacity-100 [@media(hover:none)]:opacity-100";

export const recordsTable = tv({
  slots: {
    base: [
      "relative w-full min-w-0 overflow-hidden rounded-card bg-surface shadow-card",
      "[--_grid-line:var(--fndn-line)]",
      "[--_selected:color-mix(in_srgb,var(--fndn-accent)_7%,var(--fndn-surface))]",
      "[--_selected-hover:color-mix(in_srgb,var(--fndn-accent)_11%,var(--fndn-surface))]",
    ],
    /* both axes scroll here; a wheel at the top or bottom goes on to the page, sideways overscroll
     * stays in (no back gesture: overscroll-x-contain). contain: the table's width
     * never leaks into a shrink-to-fit parent, so it scrolls here instead of widening the page.
     * A table cut at the end of the region fades into the surface there (a mask is ruled out: it
     * would cut the card's shadow). The region is a one-column grid as wide as the table, so a
     * sticky veil can share the table's area and ride the region's end edge. It shows while there
     * is more past the end, at once (no time involved): data-overflow-end, kept in step with the
     * scroll position by watchVeils (lib/veil.ts); a table that fits has none. The start side
     * needs no veil: the sticky first column covers what scrolls under it, with its own soft edge. */
    scroll: [
      "[container-type:inline-size] grid grid-cols-[minmax(min-content,1fr)] max-h-[438px] overflow-auto overscroll-x-contain",
      "[scrollbar-color:var(--fndn-line-strong)_transparent] [scrollbar-width:thin]",
      "focus-visible:outline-2 focus-visible:outline-accent focus-visible:-outline-offset-2",
      "after:content-[''] after:[grid-area:1/1] after:[justify-self:end] after:sticky after:end-0 after:z-4 after:w-6 after:pointer-events-none after:opacity-0",
      "after:bg-[linear-gradient(to_var(--_start,left),var(--fndn-surface),transparent)] rtl:[--_start:right]",
      "data-overflow-end:after:opacity-100",
    ],
    /* row numbers count the rows of the body in their current order */
    table: "[grid-area:1/1] w-full table-fixed border-separate border-spacing-0 text-sm font-medium text-ink [&>tbody]:[counter-reset:fndn-records-row]",
    headRow: "h-[35px]",
    /* header — sticky on the block axis; the first header cell is the corner and sits above all,
     * and never takes more than half of a narrow table */
    th: [
      "group/rt-th", GRID_CELL, "last:border-e-0 last:border-e-current",
      "sticky top-0 z-2 h-[35px] w-(--fndn-col-width) bg-surface text-dense font-medium text-ink-2",
      "aria-[sort=ascending]:text-ink aria-[sort=descending]:text-ink",
    ],
    thInner: "flex items-center h-[35px] min-w-0",
    /* the header's hover is a plain group variant, so the press (later, same weight) is never masked by it */
    sort: [
      "flex flex-1 items-center gap-2 min-w-0 h-full px-3 border-0 bg-transparent [font:inherit] text-inherit text-start cursor-pointer",
      "motion-colors-fast group-hover/rt-th:bg-hover group-hover/rt-th:text-ink active:bg-hover-2",
      "focus-visible:outline-2 focus-visible:outline-accent focus-visible:-outline-offset-2",
    ],
    thLabel: [
      "flex-[0_1_auto]", TRUNCATE,
      "[[data-slot=records-table-th-inner]>&]:flex-1 [[data-slot=records-table-th-inner]>&]:px-3",
    ],
    /* the arrow follows the label; it points down for ascending and turns over for descending */
    sortIcon: [
      "kbd-instant",
      "inline-flex shrink-0 text-[12px] text-ink-3 opacity-0 motion-opacity-fast motion-transform-move group-hover/rt-th:opacity-100",
      "[[data-slot=records-table-th]:is([aria-sort=ascending],[aria-sort=descending])_&]:opacity-100 [[data-slot=records-table-th]:is([aria-sort=ascending],[aria-sort=descending])_&]:text-ink-2",
      "[[data-slot=records-table-th][aria-sort=descending]_&]:[transform:rotate(180deg)]",
    ],
    /* a column's menu (a Menu's root) lies over the end of its header (the start, for numbers, whose
     * label sits at the end), so the label keeps the whole width at rest */
    colMenu: "absolute inset-y-0 end-1.5 flex items-center",
    columnsMenu: "align-middle",
    /* a larger invisible hit area keeps the triggers easy to reach in a 35px row */
    menuTrigger: "relative after:content-[''] after:absolute after:-inset-1.5",
    row: [
      "group/rt-row h-[35px] [counter-increment:fndn-records-row]",
      "[--_cell-bg:var(--fndn-surface)] hover:[--_cell-hover:var(--fndn-hover)]",
    ],
    /* body cells — one row height, truncation at the end; the full value is in title. Cells out of
     * view skip their rendering: a sort or a select-all over hundreds of rows only repaints what is
     * on screen (measured at 500 rows: about 190ms of rendering down to about 85ms) */
    cell: [
      GRID_CELL, "last:border-e-0 last:border-e-current [tr:last-child>&]:border-b-0 [tr:last-child>&]:border-b-current",
      "h-[35px] px-2 overflow-hidden text-ellipsis whitespace-nowrap bg-(--_cell-bg) [content-visibility:auto] [contain-intrinsic-size:auto_35px]",
      /* the hover is a layer over the fill (unset at rest: no image), so it is lit and unlit at once
       * while a selection under the pointer still eases the fill beneath it */
      "[background-image:linear-gradient(var(--_cell-hover),var(--_cell-hover))]",
      "group-hover/rt-row:motion-colors-fast",
    ],
    primary: "flex items-center gap-1.5 min-w-0",
    /* the row number at rest; the checkbox takes its place on hover, keyboard focus or selection.
     * Both share one grid cell, so nothing moves. */
    gutter: "grid shrink-0 place-items-center size-6 [&>*]:[grid-area:1/1]",
    rownum: [
      "text-[11.5px] font-medium tabular-nums text-ink-3 [direction:ltr] [unicode-bidi:isolate] before:content-[counter(fndn-records-row)] motion-opacity-fast",
      "group-hover/rt-row:opacity-0 pointer-coarse:opacity-0 [@media(hover:none)]:opacity-0",
      "[[data-slot=records-table-gutter]:has(:focus-visible)>&]:opacity-0 [[data-slot=records-table-gutter]:has([data-focus-visible])>&]:opacity-0",
    ],
    /* keyboard focus shows the checkbox at full strength, the header's too */
    check: "[[data-slot=records-table-gutter]:has(:focus-visible)>&]:opacity-100 [[data-slot=records-table-gutter]:has([data-focus-visible])>&]:opacity-100",
    text: ["block", TRUNCATE, "[[data-slot=records-table-primary]>&]:flex-1"],
    number: "tabular-nums [direction:ltr] [unicode-bidi:isolate]",
    /* tags are the real Tag; here they share the cell, shrink to fit and truncate */
    tags: [
      "flex items-center gap-1 min-w-0 overflow-hidden",
      "[&>[data-slot=tag]]:flex-[0_1_auto] [&>[data-slot=tag]]:min-w-6 [&>[data-slot=tag]]:max-w-[115px]",
      "[&_[data-slot=tag-label]]:[text-align:match-parent]",
    ],
    status: [
      "inline-flex items-center gap-2 max-w-full text-ink-2 [--_dot:var(--fndn-ink-3)]",
    ],
    dot: "shrink-0 size-2 rounded-[50%] bg-(--_dot)",
    link: [
      "inline-flex items-center gap-[5px] max-w-full align-middle text-accent-ink",
      "underline decoration-[color:color-mix(in_srgb,currentColor_35%,transparent)] underline-offset-3",
      "motion-colors-fast hover:text-ink hover:decoration-current",
      "focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-1 focus-visible:rounded-[2px]",
      "[&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:text-[12px]",
    ],
    linkText: TRUNCATE,
    blank: "text-ink-3",
    /* on the row menu positioner (drawn with the menu recipe), marked data-records-table="row-menu" */
    rowMenu: "",
    emptyRow: "h-[35px]",
    /* an EmptyState across every column; it takes the width of the scroll region and stays put
     * while the region scrolls, so it is always in view however wide the table is */
    empty: [
      GRID_CELL, "[tr:last-child>&]:border-b-0 [tr:last-child>&]:border-b-current",
      "[&>[data-slot=empty-state]]:sticky [&>[data-slot=empty-state]]:start-0 [&>[data-slot=empty-state]]:w-[100cqi]",
    ],
    /* selection bar — reveals under the table, so nothing above it moves.
     * fndn-check-ok: a status bar that appears with a selection, not a disclosure (no trigger) */
    selection: [
      "kbd-instant grid grid-rows-[0fr] opacity-0 motion-size-reveal motion-opacity-base",
      "[&>*]:min-h-0 [&>*]:overflow-hidden",
    ],
    selectionInner: "flex items-center gap-2 border-t border-line bg-inset",
    selectionCount: ["py-2 ps-3 pe-0 text-xs font-medium tabular-nums text-ink-2", "[unicode-bidi:plaintext] [text-align:match-parent]"],
    /* the caller's bulk actions (Buttons, a Menu), right after the count */
    selectionActions: "flex items-center gap-1 ms-1",
    selectionClear: "ms-auto me-1.5 leading-7",
  },
  variants: {
    /* which menu trigger: a column's and a row's wait for their header or row; Columns is always there */
    trigger: {
      columns: {},
      /* filled, so it covers the end of the label it lies over; it hovers and presses a step darker */
      column: {
        menuTrigger: [
          "opacity-0 group-hover/rt-th:opacity-100 focus-visible:opacity-100! aria-expanded:opacity-100!", ON_TOUCH,
          "bg-hover-2 text-ink-2 hover:bg-line-strong hover:text-ink",
          "active:bg-[color-mix(in_oklch,var(--fndn-line-strong)_75%,var(--fndn-ink-3))] active:text-ink",
          "aria-expanded:bg-[color-mix(in_oklch,var(--fndn-line-strong)_75%,var(--fndn-ink-3))] aria-expanded:text-ink",
          "aria-expanded:hover:bg-[color-mix(in_oklch,var(--fndn-line-strong)_75%,var(--fndn-ink-3))]",
        ],
      },
      row: { menuTrigger: ["inline-flex align-middle opacity-0 group-hover/rt-row:opacity-100 focus-visible:opacity-100! aria-expanded:opacity-100!", ON_TOUCH] },
    },
    /* the first column is the anchor: sticky at the inline start, with a soft edge; the first
     * header cell is the corner, above all, never more than half of a narrow table. The padding
     * keeps the specificity it had over the cells' own (a selector, not a plain utility). */
    primary: {
      true: {
        th: ["start-0 z-3 w-[min(var(--fndn-col-width),50cqi)]", EDGE],
        thInner: "gap-0.5 ps-1.5",
        sort: "[[data-slot=records-table-th]_&]:ps-1.5 [[data-slot=records-table-th]_&]:pe-3",
        thLabel: "[[data-slot=records-table-th]>[data-slot=records-table-th-inner]>&]:ps-1.5 [[data-slot=records-table-th]>[data-slot=records-table-th-inner]>&]:pe-3",
        cell: ["sticky start-0 z-1 [[data-slot=records-table-row]>&]:ps-1.5 [[data-slot=records-table-row]>&]:pe-2", EDGE],
      },
    },
    /* a number column: its values and its header align at the end; the column menu lies over the start */
    numeric: {
      true: {
        sort: "flex-row-reverse",
        thLabel: "[[data-slot=records-table-th]>[data-slot=records-table-th-inner]>&]:text-end",
        colMenu: "[[data-slot=records-table-th]>[data-slot=records-table-th-inner]>&]:start-1.5 [[data-slot=records-table-th]>[data-slot=records-table-th-inner]>&]:end-auto",
        cell: "text-end text-clip",
      },
    },
    /* the trailing column of the menus */
    actions: { true: { th: "text-center", cell: "p-0 text-center" } },
    /* a selected row: its fill, its number gives way to its checkbox */
    selected: {
      true: {
        row: "[--_cell-bg:var(--_selected)] hover:[--_cell-hover:var(--_selected-hover)]",
        rownum: "opacity-0",
      },
    },
    /* a status value's dot */
    tone: {
      neutral: {},
      green: { status: "[--_dot:var(--fndn-green)]" },
      orange: { status: "[--_dot:var(--fndn-orange)]" },
      red: { status: "[--_dot:var(--fndn-red)]" },
      accent: { status: "[--_dot:var(--fndn-accent)]" },
    },
    /* onRowOpen: a click on the row opens it (the pointer says so); the focused row (roving
     * tabindex, from the keyboard) carries the focus ring inside its edge */
    openable: {
      true: { row: "cursor-pointer outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-accent focus-visible:-outline-offset-2" },
    },
    /* the selection bar shows while rows are selected */
    open: { true: { selection: "grid-rows-[1fr] opacity-100" } },
    /* the body checkboxes wait for their row; the header's select-all is always there */
    body: {
      true: {
        check: [
          "opacity-0 motion-opacity-fast group-hover/rt-row:opacity-100", ON_TOUCH,
        ],
      },
    },
  },
  compoundVariants: [
    /* a selected row keeps its checkbox shown */
    { body: true, selected: true, class: { check: "opacity-100" } },
  ],
  defaultVariants: { trigger: "columns" },
});

export type RecordsTableRecipeProps = VariantProps<typeof recordsTable>;
```
