Data Display

Statistic

Single key metric with a label, formatted value, and optional change indicator that pairs into a statistic-group dashboard tile.

import { Statistic } from '@lostgradient/cinder';
data-displaymetric
01

Overview

Single metric tile displaying a labelled numeric value with optional trend or unit.

Choosing this component

  • Surfacing a single KPI or headline number in a dashboard or summary card (revenue, users, uptime).
  • Pairing related figures — wrap multiple Statistic tiles in StatisticGroup for consistent grid layout.
  • Showing a trend or change value alongside the primary number via the change prop.

Choosing something else

  • Code-change line counts (+/- additions and removals) — use DiffStatistics, which is purpose-built for that display.
  • Long lists of data points — use a Table or DataList instead.
  • StatisticGroup — grid wrapper for multiple Statistic tiles with shared layout.
  • DiffStatistics — specialised display for added, modified, and removed line counts.

Usage

Statistic is a compose-only leaf of StatisticGroup. The idiomatic API is StatisticGroup.Statistic, reached through the parent namespace — see the statistic-group README for the composed snippet. The leaf is also a named export of @lostgradient/cinder.

Theming

With no theme, Statistic paints its value from --cinder-text-default and its label, icon, and change description from --cinder-text-muted, keeping the background transparent. The muted token is what separates the label from the value, so it is a real token rather than an opacity on inherited text — the label is body text and has to clear the 4.5:1 contrast floor on its own.

Pass a partial theme when a statistic needs an explicit local foreground, muted color, or background — on a custom-coloured panel, for instance. Supplying a theme switches the omitted fields back to inheriting currentColor from the surrounding application, so a partial theme never mixes your explicit colours with the global tokens: theme={{ foreground: 'white', background: 'black' }} leaves the label inheriting white rather than dropping the app's dark muted token onto a black surface. To make an unthemed-looking Statistic follow an ancestor's color instead of the tokens, ask for it explicitly with theme={{ foreground: 'currentColor', muted: 'currentColor' }}.

Change direction remains visible through its arrow glyph, signed value, description, and screen-reader text rather than color alone.

Attention dot

Set attention to draw an amber dot before the label when the value is a non-zero bad count, such as items waiting on you or missed schedule runs. Leave it off for a zero count and for a healthy one, so a dot always means there is something to look at. The dot is decorative (aria-hidden) and is drawn with Highlight under forced colors; the label wording carries the meaning, so write the label to say what the count is.

svelte
<script lang="ts">
  import { Statistic } from '@lostgradient/cinder';
</script>

<Statistic label="Needs you" value={2} attention />
<Statistic label="Failed in 24 hours" value={0} />

Loading

Set loading while the figure is still being read. The label stays real text, a placeholder block holds the place of the value, and the caption is left out, so a count never reads as zero while it waits for its data. The group is marked busy and is named by its label alone. Inside a StatisticGroup the tiles keep their card chrome, so the layout does not move when the numbers arrive.

svelte
<script lang="ts">
  import { Statistic } from '@lostgradient/cinder';
</script>

<Statistic label="Running now" value={0} loading />
02

When to use

Use when
  • Highlighting one important number such as revenue, signups, or error rate.
  • Composing a dashboard tile alongside other Statistic instances inside statistic-group.
Avoid when
  • Conveying status with a short label or icon — use badge instead.
  • Showing tabular numeric breakdowns — use table or data-list instead.
03

Props

Props for statistic
Name
Type
Default
Description
label required text Short label describing the metric, e.g. "Monthly Revenue".
value required text The statistic. Strings rendered verbatim; numbers formatted via formatNumber.
attention boolean false Draws an amber attention dot before the label. Set it only when the value is a non-zero bad count (such as missed runs or items waiting on you), never on a zero or a healthy count. The dot is decorative: the label wording carries the meaning.
loading boolean false Whether the figure is still being read. The label stays real text, a placeholder block stands where the value will be and the caption is left out, so a count never reads as zero while it waits for its data. The group is marked busy and says nothing of a value.
change { /** The change magnitude as a display string, e.g. "4.75%", "+$120", "12". */ value: string; /** Direction of change — drives icon + color. */ directi…
Show full type { /** The change magnitude as a display string, e.g. "4.75%", "+$120", "12". */ value: string; /** Direction of change — drives icon + color. */ direction: StatisticChangeDirection; /** Optional visible description, e.g. "from last month". Rendered aria-hidden. */ description?: string; /** * Optional fully-worded accessible label for the change indicator. * When omitted, a phrase is synthesized from `direction` + `value` (+ optional `description`). * When provided, used verbatim — the caller owns the full wording. */ label?: string; }
Optional change indicator with direction and accessible wording.
icon snippet Optional leading icon snippet (decorative — wrapper is aria-hidden).
caption text A short muted line under the value that says what it means in words, such as "Nothing is running", "An approval and a question" or "3 done, 2 waiting on you". It describes the group for assistive technology, so state it as a sentence fragment that stands on its own.
theme ChartTheme Partial visual theme override. Omitted fields inherit the surrounding application.
valueFormatOptions Intl.NumberFormatOptions Intl.NumberFormat options applied only when value is a number.
valueLocale text Locale forwarded to formatNumber. Defaults to the nearest LocaleProvider locale, then en-US.
id text