Searching Puzzle Pieces

Type to search Puzzle Pieces.

Data Table

The interactive tier above Table: column sorting, row selection with select-all, and built-in pagination via the Pagination piece. Caller-owned snippets can customize every header label or body cell without giving up those behaviors. Sorting, selection, and page are each optional-controlled — own them in the parent, or let the table.

InvoiceClientStatusAmount
INV-1042Acme Inc.Paid1200
INV-1043GlobexPending980
INV-1044InitechPaid3450
INV-1045Umbrella Co.Overdue540
INV-1046SoylentDraft120

1–5 of 12

Installation

Copy the piece into your app — it compiles with your build and the code is yours:

puzzle add piece data-table

Pulls in the Pagination piece (a registry dependency) for the footer, and requires the pieces.css tokens merged into your app styles (see Introduction).

Usage

import DataTable from '@/components/ui/DataTable.pzl';
<DataTable columns={ columns } rows={ rows } rowKey="invoice" selectable pageSize={ 5 } />

Sorting

InvoiceClientStatusAmount
INV-1044InitechPaid3450
INV-1042Acme Inc.Paid1200
INV-1043GlobexPending980
INV-1045Umbrella Co.Overdue540
INV-1046SoylentDraft120

Sort: amount · desc

Header and body cell snippets

InvoiceClientPayment statusAmount
INV-1042Acme Inc.Paid1200
INV-1043GlobexPending980
INV-1044InitechPaid3450
INV-1045Umbrella Co.Overdue540
INV-1046SoylentDraft120

Selection

InvoiceClientStatusAmount
INV-1042Acme Inc.Paid1200
INV-1043GlobexPending980
INV-1044InitechPaid3450
INV-1045Umbrella Co.Overdue540
INV-1046SoylentDraft120

0 selected

Pagination

InvoiceClientStatusAmount
INV-1042Acme Inc.Paid1200
INV-1043GlobexPending980
INV-1044InitechPaid3450
INV-1045Umbrella Co.Overdue540

1–4 of 12

Page 1

Accessibility

  • Sortable headers set aria-sort to ascending or descending on the active <th>; the attribute is omitted (not set to "none") while unsorted.
  • Each sortable header has a real <button>, over its full label and chevron area, so headers are reachable with Tab and cycle asc → desc → off on Enter or Space. Non-sortable headers stay plain text.
  • Selection uses native <input type="checkbox">: keyboard-toggleable, each row checkbox carries an aria-label built from its key, and the header checkbox shows an indeterminate state when the current page is partially selected.
  • Every button and checkbox sets its focus outline color unconditionally, so focus rings never flash from a default color on the first frame.