Loading component…
Loading component…
The top of a dashboard – three trend cards, an overview chart that compares this period with the last, and a focus card; every number rolls when the range changes.
To reuse this local React demo, copy all files from the Code tab into the same folder, then import KPIBoard from ./kpi-board.
import { KpiBoard, type KpiBoardData } from "@/components/ui/kpi-board";
const ranges = [
{ id: "7d", label: "Last 7 days" },
{ id: "30d", label: "Last 30 days" },
];
export function Overview({ data }: { data: Record<string, KpiBoardData> }) {
// data["30d"] = { stats, overview, focus }
return <KpiBoard data={data} ranges={ranges} defaultRange="30d" compareLabel="vs. last month" />;
}| Name | Type | Default | Description |
|---|---|---|---|
| data | Record<string, KpiBoardData> | One data set per range id: { stats, overview, focus } | |
| ranges | { id: string; label: string }[] | Options of the date range picker | |
| range | string | Controlled range id | |
| defaultRange | string | first range | Starting range when uncontrolled |
| onRangeChange | (id: string) => void | Called with the new range | |
| segments | { id: string; label: string }[] | A filter inside the overview card, e.g. All items / Pro / Team – it only switches that card's lines; no filter when left out | |
| segment | string | Controlled segment id | |
| defaultSegment | string | first segment | Starting segment when uncontrolled |
| onSegmentChange | (id: string) => void | Called with the new segment | |
| compareLabel | string | "vs. last period" | Words after every change |
| currentLabel | string | "This period" | Name of the main line in the tooltip and the focus card |
| previousLabel | string | "Last period" | Name of the comparison line |
| formatMoney | (value: number) => string | $1,234.00 | Formats money values |
| icon | ReactNode | Icon in the focus card | |
| title | string | Heading on the left of the bar above the cards | |
| setup | { label: string; onClick: () => void } | The small button at the top right of the focus card, e.g. Set up | |
| action | { label: string; onClick: () => void } | The button at the bottom of the focus card | |
| className | string | Extra class on the root |
The date range sits above the cards on the right. Three small cards over a wide overview and the focus card; below 820px of container width the two lower cards take a full row each, below 600px everything stacks
It follows its container, not the window
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"