---
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 selection

A Table whose rows a person ticks to act on many at once, with a bar of bulk actions for the picked rows, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `TableSelection`.

## When to use

- A Table whose rows a person ticks to act on many at once, with a bar of bulk actions for the picked rows.

## 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 selection 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-selection.json --yes
```

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

## Usage

```tsx
import { TableSelection, useTableSelection, TableSelectAll, TableSelectRow, TableSelectionBar } from '@/components/ui/goop/table-selection';
import { useState } from 'react';
import { Table, TableHeader, TableRow, TableHead, TableBody } from '@/components/ui/goop/table';
import { TableCellLabel, TableCell } from '@/components/ui/goop/table-cell';
import { Button, ButtonLabel } from '@/components/ui/goop/button';
import { DestructiveButton } from '@/components/ui/goop/destructive-button';

function Invoices() {
  const ids = ['2026-0147', '2026-0152', '2026-0158'];
  const [picked, setPicked] = useState<string[]>([]);
  return (
    <TableSelection rows={ids} value={picked} onValueChange={setPicked}>
      <Table columns="minmax(96px, 1fr) auto" gutter="page" aria-label="Invoices">
        <TableHeader>
          <TableRow>
            <TableSelectAll />
            <TableHead>
              <TableCellLabel>Invoice</TableCellLabel>
            </TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {ids.map((id) => (
            <TableRow key={id}>
              <TableSelectRow value={id} aria-label={`Select ${id}`} />
              <TableCell>
                <TableCellLabel>{id}</TableCellLabel>
              </TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
      <TableSelectionBar>
        <Button size="sm" onClick={() => setPicked([])}>
          <ButtonLabel>Mark as paid</ButtonLabel>
        </Button>
        <DestructiveButton size="sm" icon="trash">
          Delete
        </DestructiveButton>
      </TableSelectionBar>
    </TableSelection>
  );
}
```

- Fits: list: collection.
- Also known as: RowSelection, BulkActions, SelectionBar, BatchActions, SelectAll.
- Put the box cells first in each row of a list page's Table: with `gutter="page"` (or `gutter="card"` in a card) the boxes stand on the heading's edge and the words 8 px after them, whatever is picked, with `reveal` too; in a gutterless table (a pane) the boxes get a 28 px track of their own. Not for a list of line rows (`Item variant="line"` with `ItemControl`), not to open one record (`ListDetail`), not for a form's choice (`Checkbox`, `RadioGroup`).
- height, width, padding, gap, corner, border, background, shadow, text, motion: add no class for these.

## API reference

### Parts

- `TableSelectAll` — The header's box
- `TableSelectRow` — A row's box; its props: table-selection--table-select-row.md
- `TableSelectionBar` — The bar of actions on the picked rows; its props: table-selection--bar.md
- `useTableSelection` — The selection a part sits in, read from inside a TableSelection (an action in the bar, a dialog it opens)

- data-slot values (to select a part by): table-select-all, table-select-row, table-selection, table-selection-bar

### TableSelectionBar

The bar of actions on the picked rows.

```tsx
import { TableSelectionBar } from '@/components/ui/goop/table-selection';
```

### Options

- countLabel?: (count: number) => string — The count's words for a number of picked rows; "{n} selected" by default.
- clearLabel?: string — The clear button's name, said by a screen reader: "Clear selection" by default.
- onClear?: () => void — Called after the clear button unpicks every row.
- children?: ReactNode — The actions on the picked rows.

### TableSelection: every option

```tsx
import { TableSelection } from '@/components/ui/goop/table-selection';
```

### Options

- rows: readonly string[] — The shown rows' ids, in their order: select-all and a Shift range cover these.
- value?: readonly string[] — The picked rows' ids, held by the caller.
- defaultValue?: readonly string[] — The ids picked at first, when the caller does not hold them.
- onValueChange?: (value: string[]) => void — Called with the picked ids after every change, in the rows' order.
- reveal?: boolean = false — A pointer behaviour: the boxes hidden at rest, shown under a row's pointer, under the keyboard, when checked and on every row once any row is picked; on a phone's width or a touch screen they still always show.
- State: value (value / defaultValue / onValueChange); drawn by data-empty

### TableSelectRow

A row's box.

```tsx
import { TableSelectRow } from '@/components/ui/goop/table-selection';
```

### Options

- value: string — The row's id, one of the selection's `rows`.
- aria-label: string — The box's name for assistive technology, naming the row ("Select INV-104").
- disabled?: boolean = false — A row that cannot be picked: its box dimmed, skipped by select-all and a Shift range.

## Keyboard

- Tab: move from the header's box through each row's box in row order, then to the bar's controls
- Space: pick or unpick the focused row, which becomes the anchor; on the header's box pick every shown row, or none when all are picked
- Shift+Space: set every row from the anchor to the focused one to the anchor's state
- Escape: unpick every row, from the table or the bar
- ArrowLeft / ArrowRight: move between the bar's controls

## Accessibility

- The part itself answers the keys above.
- focus-visible: the browser's own (:focus-visible): write nothing
- empty: the attribute data-empty

## 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

- [Table](/themes/trail/components/table): A data table of records compared across columns, with a header row whose columns can sort.
- [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.
- [Button](/themes/trail/components/button): A button with words that runs an action, in several looks and sizes.
- [Destructive button](/themes/trail/components/destructive-button): The button for an action that deletes or cannot be undone, marked in the danger colour.
