Analytics dashboard template
A complete store analytics page in self-contained files: an app shell with sidebar, search and a mobile drawer; a date-range switch that rescopes the page; four KPIs with deltas and sparklines; a revenue chart comparing this period with the previous one, with crosshair tooltip, keyboard reading and a table view; sales by channel as a segmented bar and ranked list; a filterable, sortable, paginated orders table; and an activity list. Fictional data sits in data.ts, ready to swap for your API.
Source
import { PackageOpen, RotateCcw, ShoppingBag, Star, UserCheck, type LucideIcon } from "lucide-react";
import { cn } from "@/lib/utils";
import type { ActivityItem } from "./data";
const KIND: Record<ActivityItem["kind"], { icon: LucideIcon; tone: string; label: string }> = {
order: { icon: ShoppingBag, tone: "bg-muted text-foreground", label: "Order" },
refund: { icon: RotateCcw, tone: "bg-rose-500/10 text-rose-700 dark:text-rose-400", label: "Refund" },
review: { icon: Star, tone: "bg-amber-500/12 text-amber-700 dark:text-amber-400", label: "Review" },
stock: { icon: PackageOpen, tone: "bg-sky-500/10 text-sky-700 dark:text-sky-400", label: "Stock" },
customer: { icon: UserCheck, tone: "bg-emerald-500/10 text-emerald-700 dark:text-emerald-400", label: "Customer" },
};
function ago(minutes: number) {
if (minutes < 60) return `${minutes} min ago`;
const hours = Math.round(minutes / 60);
return `${hours} h ago`;
}
export function RecentActivity({ items }: { items: ActivityItem[] }) {
return (
<section aria-labelledby="activity-title" className="rounded-xl border bg-card text-card-foreground shadow-xs">
<h2 id="activity-title" className="px-5 pt-5 font-semibold tracking-tight sm:px-6">
Activity
</h2>
<ol className="mt-3 px-5 pb-3 sm:px-6">
{items.map((item, index) => {
const kind = KIND[item.kind];
return (
<li key={item.id} className="relative flex gap-3 py-3">
{index < items.length - 1 && <span aria-hidden className="absolute top-12 -bottom-0 left-4 w-px bg-border" />}
<span className={cn("grid size-8 shrink-0 place-items-center rounded-full", kind.tone)}>
<kind.icon aria-hidden className="size-4" />
<span className="sr-only">{kind.label}</span>
</span>
<div className="min-w-0 flex-1">
<div className="flex items-baseline justify-between gap-3">
<p className="truncate text-sm font-medium">{item.text}</p>
<span className="shrink-0 text-xs text-muted-foreground tabular-nums">{ago(item.minutesAgo)}</span>
</div>
{item.detail && <p className="mt-0.5 truncate text-xs text-muted-foreground">{item.detail}</p>}
</div>
</li>
);
})}
</ol>
</section>
);
}
