Sidebar Dashboard Shell
Sidebar, top bar and scrollable content slot, with a mobile drawer that closes on Escape and marks the active route.
Metric row where each card knows whether a rise is good news, so churn going up is red while revenue going up is green.
components/dashboard-stat-cards.tsxnpx hoverlab add dashboard-stat-cards
Or over MCP, from your editor's agent — no account needed.
Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.
Start a page with this section — add more, order them, and leave with the page source.
Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.
/**
* <DashboardStatCards> — a KPI row with period-over-period deltas.
*
* Two things this gets right that hand-rolled versions usually do not:
*
* - Direction is an arrow *and* a colour, and "up" is not assumed to be
* good. Churn rising is red while revenue rising is green, so each stat
* declares whether an increase is positive via `higherIsBetter`.
* - The delta reads "+12.5% vs last month", not a bare "+12.5%". A
* percentage with no baseline is the most common lie on a dashboard.
*
* Server component — nothing here holds state.
*/
import * as React from 'react'
import { TrendingUp, TrendingDown, Users, DollarSign, Activity, UserMinus } from 'lucide-react'
export interface Stat {
label: string
value: string
/** Signed percentage change, e.g. `-2.4`. */
delta: number
/** False for metrics where a rise is bad — churn, latency, cost. */
higherIsBetter?: boolean
icon?: React.ReactNode
/** Baseline the delta is measured against. */
comparedTo?: string
}
export interface DashboardStatCardsProps {
stats?: Stat[]
className?: string
}
const DEFAULT_STATS: Stat[] = [
{
label: 'Monthly revenue',
value: '$48,290',
delta: 12.5,
icon: <DollarSign className="h-4 w-4" />,
},
{
label: 'Active users',
value: '2,847',
delta: 8.2,
icon: <Users className="h-4 w-4" />,
},
{
label: 'Avg. session',
value: '4m 32s',
delta: -3.1,
icon: <Activity className="h-4 w-4" />,
},
{
label: 'Churn rate',
value: '1.8%',
delta: -0.4,
higherIsBetter: false,
icon: <UserMinus className="h-4 w-4" />,
},
]
export function DashboardStatCards({
stats = DEFAULT_STATS,
className = '',
}: DashboardStatCardsProps) {
return (
<div className={`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4 ${className}`}>
{stats.map((stat) => {
const rising = stat.delta >= 0
const higherIsBetter = stat.higherIsBetter ?? true
const good = rising === higherIsBetter
return (
<div
key={stat.label}
className="rounded-2xl border border-border/60 bg-card/80 p-5 backdrop-blur transition-shadow hover:shadow-md"
>
<div className="flex items-center justify-between gap-3">
<span className="min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground">{stat.label}</span>
{stat.icon ? (
<span className="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground">
{stat.icon}
</span>
) : null}
</div>
<div className="mt-3 break-words text-3xl font-extrabold tracking-tight">{stat.value}</div>
<div className="mt-2 flex items-center gap-1.5 text-xs">
<span
className={`inline-flex shrink-0 items-center gap-0.5 font-semibold ${
good ? 'text-emerald-600 dark:text-emerald-400' : 'text-red-600 dark:text-red-400'
}`}
>
{rising ? (
<TrendingUp aria-hidden className="h-3.5 w-3.5" />
) : (
<TrendingDown aria-hidden className="h-3.5 w-3.5" />
)}
{rising ? '+' : ''}
{stat.delta}%
</span>
<span className="min-w-0 truncate text-muted-foreground">
vs {stat.comparedTo ?? 'last month'}
</span>
</div>
</div>
)
})}
</div>
)
}
bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.Drop it at components/dashboard-stat-cards.tsx and import it where you need the section:
import { DashboardStatCards } from '@/components/dashboard-stat-cards'Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.
| Prop | Type | Default |
|---|---|---|
stats | Stat[] | DEFAULT_STATS |
className | string | '' |
The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.
<!--
KPI Cards With Deltas — markup from the Hoverlab catalog.
This is the block rendered once to HTML and wrapped as a component
file. It is not a port of the React source: the Tailwind classes carry
the design, which is the part that took the work, and they are the same
in every framework.
This block has no interactive behaviour, so nothing is missing.
-->
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4 ">
<div class="rounded-2xl border border-border/60 bg-card/80 p-5 backdrop-blur transition-shadow hover:shadow-md">
<div class="flex items-center justify-between gap-3">
<span class="min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground">Monthly revenue</span>
<span class="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-dollar-sign h-4 w-4" aria-hidden="true">
<line x1="12" x2="12" y1="2" y2="22"></line>
<path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"></path>
</svg>
</span>
</div>
<div class="mt-3 break-words text-3xl font-extrabold tracking-tight">$48,290</div>
<div class="mt-2 flex items-center gap-1.5 text-xs">
<span class="inline-flex shrink-0 items-center gap-0.5 font-semibold text-emerald-600 dark:text-emerald-400"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trending-up h-3.5 w-3.5" aria-hidden="true"><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>+12.5%</span>
<span class="min-w-0 truncate text-muted-foreground">vs last month</span>
</div>
</div>
<div class="rounded-2xl border border-border/60 bg-card/80 p-5 backdrop-blur transition-shadow hover:shadow-md">
<div class="flex items-center justify-between gap-3">
<span class="min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground">Active users</span>
<span class="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-users h-4 w-4" aria-hidden="true">
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"></path>
<path d="M16 3.128a4 4 0 0 1 0 7.744"></path>
<path d="M22 21v-2a4 4 0 0 0-3-3.87"></path>
<circle cx="9" cy="7" r="4"></circle>
</svg>
</span>
</div>
<div class="mt-3 break-words text-3xl font-extrabold tracking-tight">2,847</div>
<div class="mt-2 flex items-center gap-1.5 text-xs">
<span class="inline-flex shrink-0 items-center gap-0.5 font-semibold text-emerald-600 dark:text-emerald-400"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trending-up h-3.5 w-3.5" aria-hidden="true"><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>+8.2%</span>
<span class="min-w-0 truncate text-muted-foreground">vs last month</span>
</div>
</div>
<div class="rounded-2xl border border-border/60 bg-card/80 p-5 backdrop-blur transition-shadow hover:shadow-md">
<div class="flex items-center justify-between gap-3">
<span class="min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground">Avg. session</span>
<span class="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-activity h-4 w-4" aria-hidden="true">
<path d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"></path>
</svg>
</span>
</div>
<div class="mt-3 break-words text-3xl font-extrabold tracking-tight">4m 32s</div>
<div class="mt-2 flex items-center gap-1.5 text-xs">
<span class="inline-flex shrink-0 items-center gap-0.5 font-semibold text-red-600 dark:text-red-400"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trending-down h-3.5 w-3.5" aria-hidden="true"><path d="M16 17h6v-6"></path><path d="m22 17-8.5-8.5-5 5L2 7"></path></svg>-3.1%</span>
<span class="min-w-0 truncate text-muted-foreground">vs last month</span>
</div>
</div>
<div class="rounded-2xl border border-border/60 bg-card/80 p-5 backdrop-blur transition-shadow hover:shadow-md">
<div class="flex items-center justify-between gap-3">
<span class="min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground">Churn rate</span>
<span class="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-minus h-4 w-4" aria-hidden="true">
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"></path>
<circle cx="9" cy="7" r="4"></circle>
<line x1="22" x2="16" y1="11" y2="11"></line>
</svg>
</span>
</div>
<div class="mt-3 break-words text-3xl font-extrabold tracking-tight">1.8%</div>
<div class="mt-2 flex items-center gap-1.5 text-xs">
<span class="inline-flex shrink-0 items-center gap-0.5 font-semibold text-emerald-600 dark:text-emerald-400"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trending-down h-3.5 w-3.5" aria-hidden="true"><path d="M16 17h6v-6"></path><path d="m22 17-8.5-8.5-5 5L2 7"></path></svg>-0.4%</span>
<span class="min-w-0 truncate text-muted-foreground">vs last month</span>
</div>
</div>
</div>
What each framework gets across the whole catalog — effects convert properly; this rung is markup.
The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.
Want the whole screen instead of this one section? Open a page and copy it entire.
All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.
Browse DashboardsCopying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.
Sidebar, top bar and scrollable content slot, with a mobile drawer that closes on Escape and marks the active route.
Recent-events list with typed icons and relative timestamps that keep the absolute value in a <time> element.
Breadcrumb, title, action buttons and a counted tab row that sits flush with the bottom rule.
Four columns of prioritised, tagged, assigned task cards with a blocked state — the board as a layout contract, leaving drag behaviour to your own state and library.
Events grouped by day on a vertical rail, icons varying by type and one entry expanded into a detail card — what keeps forty events scannable instead of forty gray dots.
Saved views with the third state most implementations drop: a shared view with unsaved edits, where Save changes what a colleague sees tomorrow. Two honest buttons instead of one, ownership on the tab, and dirty said in words.
A reporting window with the comparison window spelled out beside it — resolved dates, UTC arithmetic, and an option to align weekdays so a weekend is never compared against a Tuesday.
Threshold alerts with the two facts most rule lists omit: how often each has fired, and whether its channel is muted — so a rule that is on but delivering nowhere reads as its own state.