---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Table

A data table of records compared across columns, with a header row whose columns can sort, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `Table`.

## Try it

Pick a look. Sortable: sort by any column with its sort control (press again to turn it), show only unpaid invoices, remove a row and Undo it back into its place. Grouped: the invoices under a band per status, each counting its rows; a click on a band or Enter on its caret folds it, said beside the filter. Display: the Display menu picks the columns, the grouping, the sort and the density, staying open between picks. Foot: sixteen invoices in a table of fixed height, its rows scrolling under the pinned totals and pager. Narrow the stage under 641 px and the status and due columns leave, each invoice name opening its whole record.

The sort, the filter, the grouping and the pages are the example’s own: the table draws whatever rows it is handed, in that order.

## When to use

- A data table of records compared across columns, with a header row whose columns can sort.
- Also called: data table or data grid.

## When not to use

- For a simple list of rows use Item.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Table on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-table.json --yes
```

```text
Add the Goop Table to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { Table, TableHeader, TableBody, TableGroup, TableFooter, TableFooterBar, TableRow, TableHead } from '@/components/ui/goop/table';
import { TableCellSort, TableCellLabel, TableCell } from '@/components/ui/goop/table-cell';
import { Link } from '@/components/ui/goop/link';

<Table columns={['minmax(160px, 1fr)', { track: '120px', hide: 'narrow' }, '96px', { track: '82px', hide: 'narrow' }]}>
  <TableHeader>
    <TableRow>
      <TableHead sorted="ascending">
        <TableCellSort>Project</TableCellSort>
      </TableHead>
      <TableHead>
        <TableCellLabel>Owner</TableCellLabel>
      </TableHead>
      <TableHead>
        <TableCellLabel>Status</TableCellLabel>
      </TableHead>
      <TableHead>
        <TableCellLabel>Last edit</TableCellLabel>
      </TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>
        <Link variant="cell" href="/projects/transcript-search">
          Transcript search
        </Link>
      </TableCell>
      <TableCell>
        <TableCellLabel>Teodora Valk</TableCellLabel>
      </TableCell>
      <TableCell>
        <TableCellLabel>In progress</TableCellLabel>
      </TableCell>
      <TableCell>
        <TableCellLabel>13 Nov</TableCellLabel>
      </TableCell>
    </TableRow>
  </TableBody>
</Table>
```

- Fits: list, states (their recipes); list: collection (fields: many).
- By default the first column starts on the table's start edge, in line with the words around it. Where the table spans a page's whole panel under its heading (a `ListPage`, a default `PageBody`) ask for `gutter="page"`: its first column starts on the heading's edge. Straight in an outline Card, under its `CardHeader`, it takes the card's gutter by itself (`gutter="card"`, said or not); never put it in a `CardContent`. Never leave a first track empty for a gutter, and never pad a wrapper round the table. Cells have no padding of their own; every column but a row's last keeps 24 px before the next: give a column a track 24 px wider than its words.
- More on where it goes: table--options.md
- height, width, padding, gap, border, background, text, motion: add no class for these.

## API reference

### Parts

- `TableHeader` — The sticky group above the rows; put one TableRow of TableHead cells in it
- `TableBody` — The group of data rows under the header; put one TableRow per record in it, each with a key that stays with its record (its id, never its place in the list)
- `TableGroup` — Rows of a table gathered under a band, such as issues by status; its props: table--group.md
- `TableFooter` — The table's foot, pinned at its end while the rows scroll; put a totals TableRow and a TableFooterBar with the pager in it
- `TableFooterBar` — The foot's bar for the pager; summary?: ReactNode — The rows shown and of how many ("11–20 of 24"), at the bar's start
- `TableRow` — One row of cells; TableHead cells in the header's row, TableCell cells in a body row
- `TableHead` — One column's header cell, in the header's row; set sorted on the column the rows follow, numeric on an amount column; sorted?: 'ascending' | 'descending' — On the column the rows are ordered by, and which way; also takes numeric?: boolean = false; align?: 'start' | 'end' = 'start'; wrap?: boolean = false

- data-slot values (to select a part by): table, table-body, table-footer, table-footer-bar, table-footer-summary, table-frame, table-group, table-group-count, table-group-header, table-group-mark, table-group-name, table-group-rows, table-group-title, table-header, table-row

### TableGroup

Rows of a table gathered under a band, such as issues by status.

```tsx
import { TableGroup } from '@/components/ui/goop/table';
```

### Options

- value: string — The group's key (its status, its person's id): the table keeps the group's fold by it.
- title: string — The group's name, on the band and as its caret's spoken name.
- count?: number — How many rows the group holds, after its name; left out, no count.
- mark?: ReactNode — A mark before the name (a StatusMark, an avatar), decorative: the name says it.
- defaultOpen?: boolean = true — Whether the rows show at first, left to the group (open unless `false`).
- open?: boolean — Whether the rows show, held by the caller with `onOpenChange`.
- onOpenChange?: (open: boolean) => void — Called with the rows' new state when the band folds or unfolds them.

### Table: every option

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

### Compose

- An amount column: `numeric`; a row's actions menu on the table's end edge: `align="end"` on its head and cells. A column of Badges: the track `auto`, never a guessed px width (a fixed track cuts a wider pill's words). On a phone, give `columns` as a list and mark what can go (`{ track: '120px', hide: 'narrow' }`): under 640 px of the table's own width, or where the columns overflow it (a narrow panel), those columns leave, heads, cells and tracks. Keep the row's name and the one or two values a reader scans, and link the name to the record (`Link variant="cell"`). Rows in groups: one `TableGroup` per group in the `TableBody`, its rows inside it. Totals and the pager: a `TableFooter` after the body. A denser table: `density="compact"` (32 px rows).
- TableGroup: Group by one key the rows share (a status, an assignee), in that key's own order, each with its rows' count; leave out an empty group. A sort orders the rows inside each group.

### Options

- columns: string | ReadonlyArray<string | TableColumn> — The columns' tracks, a `grid-template-columns` value (`3fr 2fr 140px`) or a list of one track per column, one that leaves on a narrow table as `{ track, hide: 'narrow' }` (`['minmax(160px, 1fr)', { track: '120px', hide: 'narrow' }, '82px']`); the gutters are the table's.
- gutter?: 'none' | 'page' | 'card' — The tracks before the first column and after the last: none; `page` the page gutter (24 px), the table spanning a page's panel; or `card` a card's inset (16 px), the table in a Card.
- density?: 'comfortable' | 'compact' = 'comfortable' — The rows' height: `comfortable` (44 px rows) or `compact` (32 px rows, a group's band 32 px; a touch screen keeps 44 px), the choice a Display menu offers.
- Another example of it: table-cell.md
- Types: TableColumn = { track: string; hide?: 'narrow' }

## Accessibility

- hover, active, focus-visible: the browser's own (:hover, :active, :focus-visible): write nothing
- expanded: the attribute data-state=open
- open: the attribute data-state=open

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Item](/themes/trail/components/item): One row of a list of records.
- [Table cell](/themes/trail/components/table-cell): One cell of a data table: a value, optionally with an icon or a picture before it, inside a row.
- [Link](/themes/trail/components/link): A text link to another page or place, in running text or on its own.
- [Table selection](/themes/trail/components/table-selection): A Table whose rows a person ticks to act on many at once, with a bar of bulk actions for the picked rows.
