Loading component…
Loading component…
Sales overview – KPI cards pick the metric, one Trend Chart switches between area and bars, with top products and channels – built from Stat Card and Trend Chart.
To reuse this local React demo, copy all files from the Code tab into the same folder, then import MetricsDashboard from ./metrics-dashboard.
import { MetricsDashboard } from "@/components/ui/metrics-dashboard";
export function Overview({ days, products, channels }) {
return (
<MetricsDashboard
title="Sales"
site="Northwind Store"
data={days} // [{ date, revenue, orders, refunded }, …] oldest first
products={products} // [{ name: "Linen overshirt", share: 0.22 }, …]
channels={channels}
currency="USD"
defaultRange="30d"
onExport={(range, metric) => console.log("export", range, metric)}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| title | string | "Sales" | Title in the bar on top |
| site | string | "Northwind Store" | Site or workspace shown under the title |
| defaultRange | "7d" \| "30d" \| "90d" | "30d" | Period to start on – shown as Week, Month and Quarter |
| defaultMetric | "revenue" \| "orders" \| "aov" \| "refunds" | "revenue" | Metric to start on |
| onExport | (range, metric) => void | Called when Export is pressed; the button confirms locally either way | |
| data | { date: Date; revenue; orders; refunded }[] | sample data | One entry per day, oldest first; 180 days give every range a previous period. Days missing a number count as 0; without a previous period the cards show no change |
| products | { name: string; share: number }[] | sample products | Rows of Top products with their share of revenue (0–1); bars are relative to the largest share. An empty list shows a short note |
| channels | { name: string; share: number }[] | sample channels | Rows of Channels, like products |
| currency | string | "USD" | ISO currency code for revenue, average order and the axis |
| className | string | Extra class on the root |
Follows the block's own width with container queries: below 640px the KPI cards form a 2 × 2 grid and the lists stack
Below 460px the period switch fills the width and the chart is 168px tall
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"