StatCard
Card for one dashboard metric — label, value, icon and color, with an optional animated count
A dashboard card for one metric: a label, a value, an icon and a color, plus an optional
subtitle, badge and animated count. It comes in three looks (outlined, tinted, accent).
Import it from @telamonjs/ui (also available from @telamonjs/ui/cards,
together with StatsGrid and StatCardSkeleton).
Total Users
1.234
since last month
+12.5%Basic Usage
'use client'
import { StatCard } from '@telamonjs/ui'
import { DollarSign } from 'lucide-react'
export function RevenueCard() {
return <StatCard label='Total Revenue' value={45231} icon={DollarSign} color='green' />
}icon and color are required. Numbers are formatted with the active locale
(formatNumber, on by default); strings render as given.
Props
Prop
Type
Text that truncates — the label (unless wrapLabel), the subtitle and the tinted value —
carries its full content in a native title tooltip, so a clipped value is still readable on
hover.
There is no title, change, trend, description or footer prop. Put a delta in
badge (formatting the sign yourself) and the comparison period in subtitle. For a card
with a trend arrow and a target, use KPICard.
Examples
Variants
<StatCard variant='outlined' label='Users' value={2543} icon={Users} color='blue' />
<StatCard variant='tinted' label='Users' value={2543} icon={Users} color='blue' />
<StatCard variant='accent' label='Users' value={2543} icon={Users} color='blue' />Delta in a badge
<StatCard
label='Revenue'
value={45231}
icon={DollarSign}
color='green'
subtitle='vs last month'
badge={{ text: '+12.5%', variant: 'success' }}
/>Animated count
<StatCard label='Online' value={stats.online} icon={Activity} color='green' animate />Only numeric values animate; a string value renders immediately.
Icon by name
<StatCard label='Orders' value={127} icon='ShoppingCart' color='purple' />String icons are resolved by the resolver your app registers with setIconResolver().
Clickable
<StatCard label='Open tickets' value={12} icon={Inbox} color='red' pulse onClick={() => router.push('/tickets')} />Loading state
There is no loading prop. Render StatCardSkeleton (from @telamonjs/ui/cards)
while data is pending and swap in the cards once the values resolve.
import { StatCardSkeleton } from '@telamonjs/ui/cards'
{isLoading ? <StatCardSkeleton count={4} /> : <DashboardStats stats={data} />}Complete Example
'use client'
import { StatCard } from '@telamonjs/ui'
import { StatsGrid } from '@telamonjs/ui/cards'
import { DollarSign, Users, ShoppingCart, TrendingUp } from 'lucide-react'
interface DashboardStats {
revenue: number
revenueChange: number
users: number
orders: number
conversion: number
}
function fmtChange(delta: number) {
return `${delta >= 0 ? '+' : ''}${delta.toFixed(1)}%`
}
export function DashboardStats({ stats }: { stats: DashboardStats }) {
return (
<StatsGrid columns={4}>
<StatCard
label='Total Revenue'
value={stats.revenue}
icon={DollarSign}
color='green'
subtitle='vs last month'
badge={{
text: fmtChange(stats.revenueChange),
variant: stats.revenueChange >= 0 ? 'success' : 'destructive',
}}
/>
<StatCard label='Active Users' value={stats.users} icon={Users} color='blue' animate />
<StatCard label='Orders' value={stats.orders} icon={ShoppingCart} color='purple' animate />
<StatCard label='Conversion Rate' value={`${stats.conversion.toFixed(2)}%`} icon={TrendingUp} color='orange' />
</StatsGrid>
)
}StatsGrid from @telamonjs/ui/cards lays the cards out responsively
(columns 2–6, gap sm/md/lg); with 5 or more columns, accent cards switch to
their compact size. The root StatsGrid is a different component, used inside dialogs.
Best Practices
- Pick one variant per dashboard - mixing looks reads as noise
- Use color for meaning - green/red for good/bad, the rest for categories
- Pass numbers, not formatted strings - formatting follows the locale and
animateworks - Put the comparison period in
subtitle- keeplabelshort - Consistent grid - 2–4 columns on most dashboards
Accessibility
- With
onClick, the card renders inside a native<button> - Color is never the only signal: label and value are always text
Related Components
- KPICard - KPI card with trend arrow and target/progress
- DetailStatsGrid - Multiple stats in a detail view
- DashboardGrid - Draggable widget grid
- useAnimatedCounter - The count-up behind
animate
See Also
- Dashboard Pattern - Dashboard design