Skip to content
English
Row group table comes with Pro. Its preview shows once you unlock it.

How it works

Every group is its own tbody, so the structure is real table semantics, not a styled list. The group header row sits on a soft rounded band with a 4px surface gap above it: the first cell is one toggle button with a chevron, the group name and a row count badge, and the other cells show subtotals in semibold under their columns. Member rows are indented under the name and fade down in turn when a group opens. A footer row above a stronger line carries the grand total, and one button folds or unfolds every group. The card is an inline-size container, so columns marked hideBelow step out under 460px.

Use it for

  • Records that belong to a few groups where the subtotal per group matters: time by project, spend by category, stock by warehouse.

Look elsewhere when

  • Deep hierarchies: use the tree table.
  • Hundreds of rows per group: page or virtualise.

Usage

import { RowGroupTable } from './RowGroupTable.jsx'

export function TimeByProject({ entries }) {
  return (
    <RowGroupTable
      title="Time this week"
      caption="Billable time this week"
      rows={entries}
      groupBy="project"
      columns={[
        { key: 'task', title: 'Task' },
        { key: 'person', title: 'Person', hideBelow: true },
        { key: 'hours', title: 'Hours', align: 'right', aggregate: 'sum' },
        { key: 'amount', title: 'Amount', align: 'right', aggregate: 'sum', formatTotal: (v) => `$${v}` },
      ]}
    />
  )
}

Props

PropTypeDefaultWhat it does
columns{ key, title, align?, width?, render?, aggregate?: 'sum' | 'avg' | 'count' | 'min' | 'max' | (rows) => any, formatTotal?: (v) => ReactNode, hideBelow?: boolean }[]—The first column is the row header and holds the group toggle; aggregate fills group subtotals and the grand total.
rows / rowKeyobject[] / (row, i) => key—The data, in the order rows should appear inside a group.
groupBy / groupLabel / groupOrderstring | (row) => key / (key, rows) => ReactNode / key[] | compare—Which field groups the rows, how a group is named, and the group order (first appearance by default).
defaultCollapsedkey[][]Groups folded at first.
totalsbooleantrueA footer row with the grand total.
title / subtitle / caption / labelsReactNode / { total, expandAll, collapseAll, rows(n) }—Heading, accessible caption and every built-in string.

Accessibility

  • Each group is a tbody whose header cell has scope rowgroup; member rows have row headers.
  • The group toggle is a real button with aria-expanded, pointing at its rows with aria-controls while open; Tab reaches every toggle.
  • The row count is text in the toggle, so the collapsed size is announced.
  • Reduced motion removes the row entrance and the chevron turn.

Motion

Rows: 300ms fade down with a 28ms stagger when a group opens. Chevron: 260ms turn on the reveal curve.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

RowGroupTable.jsxrow-group-table.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Tables
Compare table comes with Pro. Its preview shows once you unlock it.
Data bar table comes with Pro. Its preview shows once you unlock it.