About
A responsive row of KPI cards with count-up numbers, up/down change badges and self-drawing trend lines. Numbers animate smoothly between values when the data changes.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Animated Stat Cards to your project and fits it to your theme.
Code
How Animated Stat Cards is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
// This is a file with a demo for your component
// That's what users will see in the preview
// Create new files in this directory to add more demos
"use client";
import * as React from "react";
import { Activity, CreditCard, ShoppingBag, UserMinus, Users } from "lucide-react";
import { Component, type StatItem } from "@/components/ui/animated-stat-cards";
import { cn } from "@/lib/utils";
/* ------------------------------------------------------------------ */
/* Sample numbers for each time range */
/* ------------------------------------------------------------------ */
const RANGES: { id: string; label: string; stats: StatItem[] }[] = [
{
id: "7d",
label: "7 days",
stats: [
{ id: "revenue", label: "Revenue", value: 11840, prefix: "$", change: 4.2, trend: [8, 9, 8.5, 10, 9.6, 11, 11.8], icon: <CreditCard className="size-4" aria-hidden="true" />, caption: "vs previous 7 days" },
{ id: "users", label: "Active users", value: 5210, change: 2.8, trend: [4.6, 4.7, 4.9, 4.8, 5, 5.1, 5.2], icon: <Users className="size-4" aria-hidden="true" />, caption: "vs previous 7 days" },
{ id: "orders", label: "Orders", value: 312, change: -1.4, trend: [48, 46, 47, 44, 45, 43, 42], icon: <ShoppingBag className="size-4" aria-hidden="true" />, caption: "vs previous 7 days" },
{ id: "churn", label: "Churn rate", value: 1.9, suffix: "%", decimals: 1, change: -0.3, positiveIsGood: false, trend: [2.4, 2.3, 2.3, 2.1, 2, 2, 1.9], icon: <UserMinus className="size-4" aria-hidden="true" />, caption: "vs previous 7 days" },
],
},
{
id: "30d",
label: "30 days",
stats: [
{ id: "revenue", label: "Revenue", value: 48250, prefix: "$", change: 12.4, trend: [18, 22, 20, 28, 26, 34, 38, 45], icon: <CreditCard className="size-4" aria-hidden="true" />, caption: "vs previous 30 days" },
{ id: "users", label: "Active users", value: 8421, change: 6.1, trend: [30, 32, 31, 36, 40, 39, 44, 47], icon: <Users className="size-4" aria-hidden="true" />, caption: "vs previous 30 days" },
{ id: "orders", label: "Orders", value: 1294, change: -3.2, trend: [40, 44, 41, 39, 42, 37, 36, 35], icon: <ShoppingBag className="size-4" aria-hidden="true" />, caption: "vs previous 30 days" },
{ id: "churn", label: "Churn rate", value: 2.4, suffix: "%", decimals: 1, change: 0.5, positiveIsGood: false, trend: [1.8, 1.9, 2, 2.1, 2, 2.2, 2.3, 2.4], icon: <UserMinus className="size-4" aria-hidden="true" />, caption: "vs previous 30 days" },
],
},
{
id: "90d",
label: "90 days",
stats: [
{ id: "revenue", label: "Revenue", value: 151900, prefix: "$", change: 18.9, trend: [60, 72, 70, 88, 95, 110, 130, 152], icon: <CreditCard className="size-4" aria-hidden="true" />, caption: "vs previous 90 days" },
{ id: "users", label: "Active users", value: 11380, change: 14.5, trend: [6, 7, 7.6, 8.4, 9, 9.8, 10.6, 11.4], icon: <Users className="size-4" aria-hidden="true" />, caption: "vs previous 90 days" },
{ id: "orders", label: "Orders", value: 3870, change: 5.7, trend: [26, 28, 29, 31, 30, 34, 36, 39], icon: <ShoppingBag className="size-4" aria-hidden="true" />, caption: "vs previous 90 days" },
{ id: "churn", label: "Churn rate", value: 2.1, suffix: "%", decimals: 1, change: -0.8, positiveIsGood: false, trend: [3, 2.8, 2.7, 2.5, 2.4, 2.3, 2.2, 2.1], icon: <UserMinus className="size-4" aria-hidden="true" />, caption: "vs previous 90 days" },
],
},
];
export default function DemoOne() {
const [range, setRange] = React.useState(1);
return (
<div className="flex min-h-[560px] w-full flex-col items-center justify-center gap-6 bg-background px-4 py-10 text-foreground">
<div className="flex w-full max-w-5xl flex-wrap items-center justify-between gap-3">
<div className="flex items-center gap-2.5">
<span className="grid size-9 place-items-center rounded-lg bg-primary text-primary-foreground">
<Activity className="size-4" aria-hidden="true" />
</span>
<div>
<h2 className="text-base font-semibold leading-5">Overview</h2>
<p className="text-xs text-muted-foreground">Key numbers for your store</p>
</div>
</div>
<div role="group" aria-label="Time range" className="inline-flex rounded-full border border-border bg-card p-0.5">
{RANGES.map((r, i) => (
<button
key={r.id}
type="button"
aria-pressed={range === i}
onClick={() => setRange(i)}
className={cn(
"h-8 rounded-full px-4 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
range === i ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:text-foreground"
)}
>
{r.label}
</button>
))}
</div>
</div>
{/* Same card ids on every range, so numbers count between values */}
<Component stats={RANGES[range].stats} />
</div>
);
}
















