Skip to content

Components

StatGroup: the key figures at the top of an overview

StatGroup sets an overview's key figures in one row: the first in display size, the others a step quieter beside it, each with its change against the previous period and a small trend line. It lays itself out by its own width rather than the window's, so the same group reads four across on a wide screen and stacks on a phone.

By Bohuslav PoláčekChecked

Ridgeway Freight's reports for the last seven days on Wednesday 2 December 2026: the headline, then shipments in display size, on-time delivery against its goal, distance and fuel use, each with its change and trend.

What it is for, and what the preview shows

The few numbers someone opens an overview to see. The preview is the top of Ridgeway Freight's reports for the last seven days as the demo shows them on Wednesday 2 December 2026, rebuilt from the kit with the demo's figures. It opens with the headline every overview has, a sentence with the numbers in it, then four figures: 648 shipments in display size, 94.0% delivered on time against a goal of 95%, 114,347 km driven and a fuel use of 28.5 l/100 km. Each carries its change against the previous seven days and a sparkline.

The colour of a change says whether it is good news, not which way it went. Fewer shipments and fewer kilometres are red, because more of both is what the business wants; lower fuel use is green; on-time delivery has not moved and says "no change" in grey. On a phone the display figure takes a row of its own and the other three wrap under it.

The rules, and where they live

  • The manifest: use it for a row of key figures on an overview, a Stat with a Sparkline each; not for a chart (ColumnChart in a ChartCard). It replaces "a grid of hand-built KPI cards".
  • AGENTS.md, Look and feel: an overview opens with its headline, a sentence with numbers drawn as Lead, and it is required; figures are StatGroup, hero by default, with one display figure a screen at 40px at most.
  • docs/principles.md, Charts: a figure's change is green or red by whether it is good news (Delta goodWhen), and "no change" when it rounds to zero.
  • docs/patterns.md, Data: figures with a trend, the first one in display size, the others a step quieter, no frame; a change that says whether it is good news.
  • docs/decisions/0009-orientation.md: the hero became the default, the boxed framed variant is deprecated, and above a list on a phone the group turns into a compact band so the list starts in the upper half of the screen.
  • scripts/check-markup.mjs: framed-stats fails <StatGroup variant="framed"> in an app.

What AI coding tools write instead

A grid of hand-built KPI cards, as the manifest's replaces names it. What goes wrong:

  • Four boxes with shadows, all the same size, so nothing says which number matters. The kit sets one figure in display size and the others beside it on the page, with no boxes.
  • A rise is green and a fall is red, whatever the figure. Fuel use falling is good news: goodWhen makes the colour follow the meaning, and a change that rounds to zero says "no change" instead of a red "−0.0%".
  • The cards break by the window's width, so a panel opened beside the page squeezes four cards into slivers. The kit's group follows its own width: four across needs 48rem, about 192px a figure.
  • The figures carry no trend, so a bad day cannot be told from a slide all week. The kit's Stat takes a Sparkline beside or under its value, and leaves it out on a phone.
  • Nothing above the cards says what they add up to. The kit's overview opens with the Lead sentence first: 648 shipments in seven days, below the goal.

How to use it

  • StatGroup holds Stat children; variant is hero by default, or open for figures with air between them and no frame.
  • Stat: label, value, hint (usually a Delta) and chart (a Sparkline); hero makes another figure the display one.
  • Delta: value (0.034 is +3.4%), kind (percent, points for a rate, absolute with a unit), goodWhen (up or down) and suffix, what it is measured against.
  • Sparkline: the period's values, drawn to their own range.
  • Lead above the group carries the overview's headline.

Its entry in the manifest

The component's rules as the kit's manifest states them, the same entry an AI coding tool reads.Read from the kit's component manifest when the site was built (126 components, packages/kit/src/components.json); the same entry answers an AI coding tool through the kit's MCP server.

Where it runs in the example apps

The example apps whose code renders a StatGroup, and the modules it sits in.Read from the demo's source when the site was built: 9 of 9 example apps render <StatGroup>, in the modules named here as each app's sidebar names them.

How the demo calls it

apps/demo/src/modules/analytics/pages/analytics.tsx
<StatGroup key={index}>
  {widget.items.map((kpi) => {
    const base = formatter(kpi.format);
    const format = (value: number) => (kpi.unit ? `${base(value)} ${kpi.unit}` : base(value));
    return (
      <Stat
        key={kpi.label}
        label={<KpiLabel kpi={kpi} />}
        value={
          <AnimatedNumber
            value={
              kpi.format === "percent"
                ? Math.round(kpi.value * 1000) / 1000
                : kpi.format === "decimal"
                  ? Math.round(kpi.value * 10) / 10
                  : Math.round(kpi.value)
            }
            format={format}
          />
        }
        hint={<KpiHint kpi={kpi} />}
        chart={kpi.trend ? <Sparkline values={kpi.trend} /> : undefined}
      />
    );
  })}
</StatGroup>
Ridgeway's reports: one Stat per figure, the label with its goal, the value rolling to its new number, the change as the hint and the trend as a sparkline.

Questions

Which figure is shown large?

The first Stat in a hero group, unless another one says hero. A screen has one display figure, at most 40px, and the rest sit beside it a step quieter.

How does the change know whether it is good news?

Delta takes goodWhen, up or down. Shipments falling is red, fuel use falling is green, and a change that rounds to zero at one decimal is a grey no change.

What happens on a phone?

The group follows its own width. Below 48rem the display figure takes its own row, because a 30px figure does not fit half of a 390px screen, and the others wrap under it. Above a list on a phone the group becomes a compact band of two figures a row.

Can the figures sit in boxes?

No. The boxed framed variant is deprecated and the markup check fails it in an app. Use the hero, or open for numbers that sit on the page with air between them.

Two ways

Build it yourself, or have it built

  • Build it yourself

    Build your app on the framework

    Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.

    One payment, lifetime updates

    Get the framework
  • Have it built

    Have us build your app

    Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.

    After launch, Care keeps it improving, from €99 a month.

    from €1,990

    Describe your app