Components/Metric Card

Metric Card

A richer KPI card for dashboards: label, value, percentage delta, inline sparkline, and a status accent. A drop-in upgrade over the plain Stat when you need a trend chart at-a-glance.


Monthly revenue
$48,294
12.4%vs last month

Installation

npx ajaxui add metric-card

Accents

The accent prop adds a subtle ring + status dot. Use it to convey health (success / warning / danger) without changing layout.

Active users
12,540
4.2%
Uptime
99.98%
0.1%
API latency
312 ms
5.6%
Error rate
2.4%
8.1%

Without sparkline

Omit sparkline for a compact card — perfect for sidebars or dense 4-column grids.

MRR
$48k
12.4%
Customers
2,108
3.6%
Churn
1.2%
0.4%

Loading

Set loading to render skeletons while data is in flight. Layout stays stable.

Monthly revenue

Props

PropTypeDefaultDescription
labelstringShort caption shown above the value.
valueReactNodeThe headline figure (pre-formatted string or node).
changenumberPercentage delta. Sign drives trend direction.
changeLabelstringCaption next to the delta (e.g. "vs last month").
trend"up" | "down" | "neutral"autoOverride the trend computed from change.
sparklinenumber[]Series rendered inline. 8–24 points works best.
iconReactNodeTop-right icon slot.
accent"default" | "success" | "warning" | "danger" | "info""default"Adds a colored ring and status dot.
footerReactNodeOptional footer slot (links, actions).
loadingbooleanfalseRenders a skeleton in place of value/sparkline.

Accessibility

  • Each card renders as an <article> with an accessible name derived from label.
  • The delta is announced as e.g. "up 12.4 percent vs last month", not just the arrow glyph.
  • The sparkline is purely decorative (aria-hidden) — the value text remains the source of truth.