Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

Stat card

A headline number that counts up, a trend pill and a chart in one card.

Revenue +12.4%
48,200 vs last month
Orders -3.1%
1,284 vs last month
Uptime +0.2%
99 30 days

Installation

pnpm add @heyramzi/ui

Usage

import { StatCard } from "@heyramzi/ui/charts";
<StatCard
  label="Revenue"
  value={48200}
  delta={12.4}
  caption="vs last month"
  variant="area"
  data={[{ m: "Jan", v: 3200 }]}
  xKey="m"
  yKey="v"
/>

Keyboard and accessibility

  • The label and value are plain text. The trend chart is an image named by the label plus "trend".
  • The change arrow is hidden from screen readers.

API reference

data TData[]
Default []
Series for the line/area/bar variants. Unused by the gauge variant.
xKey keyof TData & string
yKey keyof TData & string
variant "line" | "area" | "bar" | "gauge"
Default "area"
Chart kind. "gauge" puts a radial gauge to the right of the figure.
gaugeValue number
Arc fill 0-100 for variant="gauge". Falls back to `value` when numeric.
gaugeLabel string
Label under the gauge percentage.
label string
Metric name shown top-left. Omit (or set `figureOnly`) for a bare chart.
value number
Headline number; counts up on mount.
delta number
Percentage change. Its sign drives the trend color/arrow unless `trend` is set.
trend "up" | "down" | "neutral"
Force the trend direction independent of `delta`'s sign.
caption string
Caption under the value, e.g. "Avg" or "vs last month".
figureOnly boolean
Default false
Render only the edge-to-edge chart, no header/value/caption.
color string
Default "var(--chart-series-1)"
height number
Default 150
Chart height in px.
smooth boolean
Default true
edgeFade boolean | number
Default true
Softens the left and right ends of the line and the area fill instead of cutting them off at the card edge.
formatValue (v: number) => string
Default (v) => v.toLocaleString()
Format for the headline value.
formatX (v: unknown) => string
Default (v) => String(v)
Format for the x value shown as the tooltip header (e.g. a date/period).
icon Snippet
Leading icon next to the label.
class string
Prop Type Default
data

Series for the line/area/bar variants. Unused by the gauge variant.

TData[] []
xKey keyof TData & string
yKey keyof TData & string
variant

Chart kind. "gauge" puts a radial gauge to the right of the figure.

"line" | "area" | "bar" | "gauge" "area"
gaugeValue

Arc fill 0-100 for variant="gauge". Falls back to `value` when numeric.

number
gaugeLabel

Label under the gauge percentage.

string
label

Metric name shown top-left. Omit (or set `figureOnly`) for a bare chart.

string
value

Headline number; counts up on mount.

number
delta

Percentage change. Its sign drives the trend color/arrow unless `trend` is set.

number
trend

Force the trend direction independent of `delta`'s sign.

"up" | "down" | "neutral"
caption

Caption under the value, e.g. "Avg" or "vs last month".

string
figureOnly

Render only the edge-to-edge chart, no header/value/caption.

boolean false
color string "var(--chart-series-1)"
height

Chart height in px.

number 150
smooth boolean true
edgeFade

Softens the left and right ends of the line and the area fill instead of cutting them off at the card edge.

boolean | number true
formatValue

Format for the headline value.

(v: number) => string (v) => v.toLocaleString()
formatX

Format for the x value shown as the tooltip header (e.g. a date/period).

(v: unknown) => string (v) => String(v)
icon

Leading icon next to the label.

Snippet
class string