StealThis .dev

KPI Card

A compact Key Performance Indicator card with animated counter, trend arrow (up/down), sparkline background, period selector, and color-coded status. Perfect for dashboards and analytics pages.

Open in Lab
css react tailwind vue svelte
Targets: TS JS HTML React Vue Svelte

Code

Features

  • Animated counter — value counts up from 0 on mount
  • Trend arrow — up/down arrow with green/red color based on delta
  • Percentage delta — shows change vs previous period
  • Period selector — 7d / 30d / 90d tabs update displayed data
  • Status indicator — color dot for on-track / at-risk / behind

How it works

  1. CSS @keyframes and a JS counter animate the number display
  2. Delta % is computed as (current - previous) / previous * 100
  3. A positive delta renders an upward green arrow; negative renders red down arrow
  4. Period selector swaps pre-defined data sets and re-triggers the counter animation