โœฆ StealThis .dev

Stat Card

Metric stat cards with KPI value, trend badge (up/down %), supporting label, and optional sparkline bar.

Open in Lab
css
Targets: HTML

Code

Stat Card

Dashboard KPI cards that surface a single key metric at a glance. Each card shows a value, a trend badge (up or down percentage), a descriptive label, and an optional inline sparkline bar chart.

Features

  • Trend badge โ€” green for positive, red for negative delta
  • Sparkline bar โ€” seven-bar mini chart using pure CSS custom properties
  • Icon slot โ€” optional icon in the card header for context
  • Grid layout โ€” responsive 2-col / 4-col grid with CSS Grid
  • CSS-only โ€” zero JavaScript, sparkline heights set via inline --h custom properties

Anatomy

[Icon]     [Label]          [Trend +12%]
[Value: $48,392]
[Sparkline bars โ–โ–‚โ–„โ–†โ–‡โ–ˆโ–…]
[Supporting text]

Usage

Set the sparkline bar heights by adding style="--h: 60%" to each .bar element. Values are percentages relative to the bar container height.