Statistics card
A metric with an optional icon and an up, down or flat percentage change.
Preview
Counts up to its number once it scrolls into view, then lifts on hover. With reduced motion turned on, it renders the plain layout.
Monthly active users
125,430
Up+12.5% vs last month
Monthly active users
125,430
Up+12.5% vs last month
Installation
Run this in a project that already uses shadcn/ui. It adds the component and anything it needs; the motion version also adds the plain one and the motion package.
Usage
import { StatisticsCard } from "@/components/custom/statistics-card";
<StatisticsCard
title="Monthly active users"
value="125,430"
change={12.5}
changePeriod="vs last month"
icon={Users}
/>import { StatisticsCardMotion } from "@/components/custom/statistics-card/statistics-card-motion";
<StatisticsCardMotion {...props} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title* (required) | string | – | Metric name. |
| value* (required) | string | number | – | The number to show. |
| change | number | – | Percentage change; positive, negative or zero sets the trend. |
| changePeriod | string | "from last month" | What the change compares against. |
| description | string | – | Extra line under the value. |
| icon | LucideIcon | – | Icon next to the title. |
| iconColor | string | "text-primary" | Tailwind classes for the icon color. |
| prefix | string | "" | Text before the value, such as $. |
| suffix | string | "" | Text after the value, such as %. |
| ...props | React.ComponentProps<"div"> | – | Any other div attribute (id, aria-*, data-*, ref) goes to the root element. |
| Prop | Type | Default | Description |
|---|---|---|---|
| title* (required) | string | – | Metric name. |
| value* (required) | string | number | – | The number to show. |
| change | number | – | Percentage change; positive, negative or zero sets the trend. |
| changePeriod | string | "from last month" | What the change compares against. |
| description | string | – | Extra line under the value. |
| icon | LucideIcon | – | Icon next to the title. |
| iconColor | string | "text-primary" | Tailwind classes for the icon color. |
| prefix | string | "" | Text before the value, such as $. |
| suffix | string | "" | Text after the value, such as %. |
| ...props | React.ComponentProps<"div"> | – | Any other div attribute (id, aria-*, data-*, ref) goes to the root element. |
Accessibility
- The trend arrow has a visually hidden label, so the direction is not conveyed by color alone.
- The motion version follows the visitor's reduced-motion setting and never hides content before it animates.