When to use a KPI card
KPI cards summarize one metric at a glance, usually in a row at the top of a dashboard.
- MRR, revenue, or orders this month
- Active users with week-over-week change
- Conversion rate with its recent trend
Data format
- Use 2 columns: Period,Value, oldest first. The last row is the headline value.
- The change badge compares the last two non-blank values.
- Paste CSV, JSON from your API, TSV copied from Excel or Google Sheets, or a Markdown table. The generated component keeps your column names as its data keys.
Month,Revenue
Jan,42000
Feb,45800
Mar,44100
Apr,51200
May,56900
Jun,61400[
{"month": "Jan", "revenue": 42000},
{"month": "Feb", "revenue": 45800},
{"month": "Mar", "revenue": 44100},
…
]Options
- Sparkline
- Area, line, or bar sparkline.
- Color
- Custom sparkline color.
How to add it to your project
- 1. Add the shadcn/ui chart component (it installs Recharts):
npx shadcn@latest add chart - 2. Paste your data above, pick the options, and copy the generated
chart.tsx. - 3. Save it in your project (e.g.
components/kpi-chart.tsx) and render<Chart />, or<Chart data={rows} />in Data as prop mode.
KPI Sparkline Card FAQ
From the last two non-blank values: (latest − previous) / previous. It's computed inside the component, so it stays correct with live data.
Yes. The component fills its container's width, so drop several into a grid like grid-cols-1 sm:grid-cols-3.
Area and line sparklines fit the data's min to max so the trend is visible. The bar variant keeps a zero baseline.