Grouped Table
GroupedTable is a record list’s List view. Each group is a card: a color block header (the group’s label, its indicators, then the screen’s meta) over a neutral body of rows. The whole header folds the rows away. Expand all and Collapse all sit above the table while there is more than one group, or move to the toolbar (see Controlled collapse).
Live demo
Fold a group, use Expand all and Collapse all, and turn grouping off for one flat table.
| PO | Vendor | Job | Total |
|---|---|---|---|
| PO-1041 | Ferguson | Oak Hollow Clubhouse | $4,820 |
| PO-1042 | Core & Main | Wells Branch Senior Living | $12,950 |
| PO-1043 | Viking Supply | Round Rock Denny's | $2,310 |
| PO-1044 | Ferguson | Riverbend Phase 2 | $8,075 |
Group cards, by vendor type, job type and client
Switch the grouping. A color belongs to the type, so it does not move when a filter removes a group. Click a sortable head twice to flip ascending and descending.
| Job, client, vendor | ||
|---|---|---|
| PO-1041 | Oak Hollow Clubhouse Hines · Ferguson | $4,820 |
| PO-1044 | Riverbend Phase 2 No client · Viking Supply | $8,075 |
| PO-1042 | Wells Branch Senior Living Hines · Core & Main | $12,950 |
| PO-1043 | Round Rock Denny's Weston · Reed Fire Services | $2,310 |
| PO-1045 | Riverbend Phase 2 Atlas · Lone Star Testing | $1,250 |
Color
A group’s tone is a numbered slot, an ombre, or neutral. The component takes the slot; the page maps its data to it (apps/web/src/lib/group-tones.ts).
| Grouping | Tone |
|---|---|
| Vendor type | slotTone(1..3) for material, service, subcontractor; anything else slot 8 |
| Job type | slotTone(1..3) for 13D, 13C, 13F; anything else slot 8 |
| Client | ombreTones(count), one step per group in display order |
| Status, No grouping | none (neutral) |
Ombre. The base is group-tone-1. For count groups, step i (0-based) has strength p(i) = 100 - i * min(10, 60 / (count - 1)) percent, and 100 for one group, so it never goes below 40. The fill is color-mix(in srgb, var(--group-tone-1) p%, var(--card)). Text is --group-tone-1-fg when p >= 60, else --foreground.
Indicators
indicators draws small pills on the header, a tone dot and a count, with the label as tooltip and accessible name. The page computes them for the group’s rows. A count of 0 is not drawn.
Controlled collapse
The toolbar calls useGroupCollapse(groupKeys), passes collapsed and onCollapsedChange to the table with bulkControls="none", and wires its Expand all and Collapse all buttons to expandAll and collapseAll. Without them the table keeps its own state and draws its own buttons.
Sortable heads
A column with sortable has a head button. The first click reports ascending, the next flips. The table does not sort: the page orders groups and rows from sort and onSortChange.
Row identity
Every row’s identity cell shows the job and the client, and the vendor where one applies (Purchase Orders, Subcontracts, Bills). A missing part reads in the destructive color (“No client”). Use RecordIdentity for it, and in phoneRow too.
Behavior
- Every group starts open. A screen that switches views or regroups remounts the table with a new
key, which opens every group. - Grouping off renders one flat table with no group rows.
- A column can fold away on a phone with
hideOnPhone.
Usage
import { GroupedTable } from "@beacon/design-system";
<GroupedTable columns={[{ key: "number", header: "PO", render: (o) => o.number }]} groups={[{ key: "sent", label: "Sent", meta: "2", rows: sentOrders }]} grouped getRowKey={(o) => o.id} empty="No purchase orders"/>;Props
| Prop | Type | Description |
|---|---|---|
columns | GroupedTableColumn<T>[] | key, header, render, and optionally align, hideOnPhone, hideOnTablet and sortable. |
groups | GroupedTableGroup<T>[] | key, label, optional meta, tone and indicators, and the group’s rows. |
collapsed, onCollapsedChange | optional | Controlled collapse; the keys of the collapsed groups. |
bulkControls | "inline" | "none" | "none" when the toolbar owns Expand all and Collapse all. |
sort, onSortChange | optional | The sorted column, and the head click. |
grouped | boolean | False renders one flat table. |
getRowKey | (row) => string | A row’s identity. |
onRowClick, rowHighlighted | optional | Open a record; highlight one. |
empty | ReactNode | Shown when no group has a row. |