Skip to content
satin

Grouped table

Pro

A Table whose rows open onto sub-rows and gather into groups with subtotals, with a pinned first column, a totals row and a compact density.

OwnerWeighted
Qualified1 row
€22,50030%€6,750
Globex
Jon Park€22,50030%€6,750Jan 20
Proposal2 rows
€79,20048%€38,040
Acme Corp
Tara Mendes€48,00050%€24,000Dec 12
Platform licence
€36,000
Onboarding
€12,000
Initech
Tara Mendes€31,20045%€14,040Dec 19
Negotiation2 rows
€75,30068%€51,765
Hooli
Ada Novak€18,90065%€12,285Dec 8
Total€253,30066%€172,855

Installation

Terminal
npm i @uisatin/ui @uisatin/pro
Import
import '@uisatin/ui/styles.css'
import '@uisatin/pro/styles.css'
import { TableGrouped, type TableGroupedColumn } from '@uisatin/pro/table-pro'

Part of Satin Pro, the licensed edition: @uisatin/pro on top of @uisatin/ui at the same version, its stylesheet after Free's. Satin Pro isn't on npm yet.

About 4.1 kB of JavaScript, minified and gzipped, on top of the @uisatin/uicomponents it uses (React aside).

First time with Satin? Set it up once, styles and fonts included, with the installation guide.

API Reference

The TableGrouped component (Satin Pro, @uisatin/pro/table-pro) is Table, with every Table prop, plus: getSubRows opens rows onto rows of their own; groupBy gathers rows under a header row per value, with the count and each column's subtotal (renderGroup draws the name, groupOrder sets the order); a column's format writes its numbers and aggregate ("sum", "avg", "min", "max", "count" or (rows) => number) totals them in group headers and the footer row, a tfoot; pinned="start" keeps the first column in place with a shadow over what scrolls under it. Totals count the rows you pass, not their sub-rows. With sub-rows or groups the table is a treegrid. The part TableRowToggle is the chevron, for a Table of your own; aggregateRows(rows, column) gives a total as a number.

PropTypeDefault
columns
TableGroupedColumn[]
—
rows
Row[]
—
getSubRows
(row: Row) => Row[] | undefined
—
expanded
string[]
—
defaultExpanded
string[]
[]
onExpandedChange
(ids: string[]) => void
—
groupBy
keyof Row
—
groupOrder
string[]
—
renderGroup
({ value, rows }) => ReactNode
—
collapsedGroups
string[]
—
defaultCollapsedGroups
string[]
[]
onCollapsedGroupsChange
(values: string[]) => void
—
pinned
"start"
—
footer
boolean
false
density
"default""compact"
"default"
selected
string[]
—
defaultSelected
string[]
[]
column.format
(value: number) => ReactNode
—
column.aggregate
"sum""avg""min""max""count"(rows) => number
—

Accessibility

Table as it is (named by label, aria-sort on sortable headers, named checkboxes), plus: with sub-rows or groups the table takes role="treegrid", and its body rows carry aria-level, aria-posinset, aria-setsize, aria-expanded when they open and aria-selected when selectable. One row is in the Tab order at a time; the row checkboxes stay in it too, as in Table. Each chevron is a button named "Rows under <name>" with aria-expanded, left out of the Tab order because the row's keys do the same. A group header's name is its row header and its count reads "3 rows"; the totals row sits in a tfoot with a "Total" row header. The pinned column's shadow is decoration.

KeyAction
↓or↑Moves to the next or previous row, group headers included.
HomeorEndMoves to the first or last row.
→Opens a closed row or group; on an open one, moves to its first row. Mirrored right to left.
←Closes an open row or group; otherwise moves to the row or group it sits under. Mirrored right to left.
EnterOpens or closes the row or group.
SpaceWith selectable, picks or drops the row, or every row of a group.
EnterorSpaceOn a sortable header: sorts ascending, then descending, then not at all, inside each group.