MetricCard
A single metric tile with label, value, color-aware delta arrow, optional sparkline, icon, and loading state.
Props
MetricCard extends HTMLAttributes<HTMLDivElement> (omitting onClick).
| Prop | Type | Default | Description |
|---|---|---|---|
metric | MetricDatum | — | Data object with label, value, delta, intent, etc. |
variant | "bordered" | "plain" | "bordered" | Drops the border when plain. |
MetricDatum fields:
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | — | Metric name above the value. |
value | ReactNode | — | The headline number or string. |
unit | ReactNode | — | Small label after the value. |
delta | number | — | Period-over-period change. Sign drives the arrow. |
formatDelta | (delta: number) => string | — | Custom formatter. Defaults to signed percentage. |
intent | "positive" | "negative" | "neutral" | — | Color of the delta. Defaults to sign-based inference. |
caption | ReactNode | — | Dim caption under the value. |
spark | number[] | — | Trend series shown as a mini sparkline. |
sparkColor | string | — | Override sparkline color. |
icon | ReactNode | — | Leading icon in the label row. |
loading | boolean | — | Renders muted with a shimmer. |
onClick | () => void | — | Makes the card clickable. |
Examples
Positive delta
Negative delta with intent
Flat (no change)
With sparkline
With icon
Loading
Revenue
Bordered vs plain
import { MetricCard } from "@solarius/onset";
import type { MetricDatum, MetricCardProps } from "@solarius/onset";