Metric card
A React component in Beamline's Dashboard category.
A KPI that fills its tile: label, a value that rolls to each new number, the change with arrow, sign and tone, what it compares with and the value it was, a trend line and context; a wide tile sets the trend beside the figures. Unmeasured values are hatched, never zero.
Use it for
- Headline numbers on dashboards, in any tile from a narrow side column to a full-width band.
Not for
Anatomy
- root (m-surface card, a size container; bezel frame: shell + inset panel, the panel is the container)
- layout: one column; in a wide tile (≥ 28rem) the figures' column and the trend beside it
- label
- value (slot text, LTR-isolated figures; xl under 12rem, 2xl, 3xl in a wide tile)
- change line: delta badge (one triangle that turns over, sign, unit; a new figure fades in) + comparison (deltaLabel) + previous (“· was $42,900”), read as one phrase
- trend line (36 px under the figures; 64 px beside them in a wide tile)
- context (pinned to the bottom so cards in a row align; two lines at most)
- unfold toggle (a chevron in the corner; in the bezel frame, in the footer) and the insides: history at full size, now against the compared value, the query and its source
Variants
- frame: plain, bezel
States
- up good
- up bad (invert)
- flat
- not measured (hatched swatch + “Not measured”, no badge)
- percentage points (pp)
- loading (`loading`: the label, value line, change row, trend and context hold their real heights with placeholders; a row is held when its prop is given, an empty label holds the label's line)
- reading the trend (pointer along the trend: a dot and guide on the point, its value — and name, with trendLabels — above it; the label never leaves the trend)
- open (useUnfold): grown where it stands, the trend drawn once as the history, the insides arriving section by section after the box
Keyboard
- Not interactive
- Enter or Space on the toggle opens and folds; Escape inside an open card folds it and focus returns to the toggle
Motion
The value rolls to new numbers (SlotText) and a new change fades in where the old one stood (--pui-fade-in). The change's triangle turns over (rotate, --pui-duration-morph) when up becomes down, and its tone cross-fades (--pui-duration-standard). Crossing a room step the value's size eases; the layout changes at once. The previous value arrives with attention like every .reveal (0 ms in, --pui-motion-out out). Reduced motion: the numbers swap, the triangle and size change at once. Unfolding eases the card's height where it stands (--pui-duration-morph) and the insides fade in one section after another; reduced motion places at once.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | |
value / format | number | null / (v) => string | — | value: null when it is not measured: shown hatched with “Not measured”, never as 0. format: How the value (and the previous one) is written. A function cannot cross from a server component: there, use formatOptions, locale, prefix and suffix, which do the same with plain values. |
delta / deltaLabel / invert | number / string / boolean | — | delta: Change in deltaUnit: 0.064 for +6.4% (fraction), -9 for −9 percentage points. deltaLabel: What the change compares with: "vs last month". invert: Down is good (churn, latency): a fall reads green. |
previous | number | null | — | The value it compares with (last month's), in the value's own units and written the same way as the value (format, prefix, suffix): "was $42,900" beside the comparison. It shows in a roomy card and arrives with attention (hover, focus inside) in a smaller one; unfolded, it is the bar under the value's. |
trend | (number | null)[] | — | Recent values for the trend line, oldest first. Pointing along the trend reads each one. |
trendLabels | string[] | — | Names for the trend's points ("12 Sep"), shown with the value while pointing along the trend. |
context | ReactNode | — | One line of context under the value. |
frame | "plain" | "bezel" | — | plain: one surface. bezel: value and trend set into an inset panel. |
deltaUnit / deltaFormat | "fraction" | "percentage-points" / (delta: number, unit: MetricDeltaUnit) => string | — | Fraction preserves the existing relative percentage API. Percentage-points uses an already calculated point change: -9 reads −9 pp and down 9 percentage points. A custom display formatter does not replace the accessible unit. |
style / ref | CSSProperties / native Ref | — | style: Inline styles on the documented visual root; no overrides by default. ref: Receives the documented native target or imperative handle; omitted by default. |
headingLevel | 2 | 3 | 4 | 5 | 6 | — | The plain frame's label is a heading: its level, so cards nest under the page's own headings (default 3). |
classNames | MetricCardClassNames | — | Classes for the named visual parts; no overrides by default. |
trendClassNames | TrendLineClassNames | — | |
loading | boolean | false | While the number loads: the value, change, trend and context are placeholders of their real height. A row is held when its prop is given (`delta={0}`, `trend={[]}`, `context`), and an empty `label` holds the label's line too. |
formatOptions / locale / prefix / suffix | Intl.NumberFormatOptions / string / string / string | — | formatOptions: Intl options for the value: `{ style: "currency", currency: "USD", maximumFractionDigits: 0 }`. locale: The locale the value is written in. Defaults to the enclosing UIRoot locale. prefix: Written before the value: "$". suffix: Written after the value: " ms", " min". |
style | CSSProperties | — | Inline styles on the documented visual root; no overrides by default. |
ref | Ref<HTMLElement> | — | Receives the documented native target or imperative handle; omitted by default. |
value (required) | number | null | — | null when it is not measured: shown hatched with “Not measured”, never as 0. |
format | ((value: number) => string) | — | How the value (and the previous one) is written. A function cannot cross from a server component: there, use formatOptions, locale, prefix and suffix, which do the same with plain values. |
formatOptions | NumberFormatOptions | — | Intl options for the value: `{ style: "currency", currency: "USD", maximumFractionDigits: 0 }`. |
locale | string | — | The locale the value is written in. Defaults to the enclosing UIRoot locale. |
prefix | string | — | Written before the value: "$". |
suffix | string | — | Written after the value: " ms", " min". |
delta | number | null | — | Change in deltaUnit: 0.064 for +6.4% (fraction), -9 for −9 percentage points. |
deltaUnit | MetricDeltaUnit | — | |
deltaFormat | ((delta: number, unit: MetricDeltaUnit) => string) | — | Format the visible change; the accessible name still states the explicit unit. |
deltaLabel | string | — | What the change compares with: "vs last month". |
invert | boolean | — | Down is good (churn, latency): a fall reads green. |
className | string | — | Classes on the documented visual root; no override by default. |
query / source | string / ReactNode | — | query: The query or formula behind the number (SQL, a metric definition). With it (or `source`) the card unfolds in place into its insides: the history at full size, the value against the one it compares with, and this. source: Where the number comes from and when ("Stripe · updated 3 min ago"), shown unfolded under the query. |
open / defaultOpen / onOpenChange | boolean | — | open: Controlled: whether the card shows its insides; omit to use defaultOpen. defaultOpen: Uncontrolled start; default false. onOpenChange: Reports an open-state change; no callback by default. |
query | string | — | The query or formula behind the number (SQL, a metric definition). With it (or `source`) the card unfolds in place into its insides: the history at full size, the value against the one it compares with, and this. |
source | ReactNode | — | Where the number comes from and when ("Stripe · updated 3 min ago"), shown unfolded under the query. |
open | boolean | — | Controlled: whether the card shows its insides; omit to use defaultOpen. |
defaultOpen | boolean | — | Uncontrolled start; default false. |
onOpenChange | ((open: boolean) => void) | — | Reports an open-state change; no callback by default. |
Built from
Used in
- Agent monitor
- Agent runs monitor
- Analytics dashboard
- Course dashboard
- CRM pipeline
- Email automation
- Invoices
- Order history and fills
- Orders admin
- Portfolio overview
- Project board
- Sales dashboard
Import
import { MetricCard } from "@beamline/metric-card";
Get it
Metric card is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent
More in Dashboard
- Explainable total: A total that answers "why this much?" in place: it unfolds into the steps that made it — a waterfall whose bars start where the last step ended, each…
- Explainable change: A metric whose change explains itself: at rest the value, the change against a named period and a thin ribbon of its causes under the change; opened in…
- Budget vessels: Budgets as glasses of money: the liquid is what is left (free money on top, committed money as a lighter layer under it), the lip at the period's budget…
- Insight cards: Findings from an agent, one per page: the sentence, the series it is about with their change, a chart to scrub that names each point, and a follow-up…
- Tracker: A row of status blocks for uptime, job runs or daily checks, with tooltips and a legend.
- Category bar: One bar split into labelled ranges with an optional marker that names its range.
- Bar list: Ranked horizontal bars, label and value over a meter, one line per row when there is room — top pages, sources, customers.
- App shell: The frame for every app screen: collapsible sidebar with grouped navigation, top bar and page.