Web analytics dashboard
Visitors, sources and pages on one screen: visitors, sessions, bounce rate and average time as headline numbers, visitors against the previous period, visitors right now, top pages, traffic sources, visits by weekday and hour, and devices. Every section is optional and the layout closes up around a missing one. For revenue pick the sales or SaaS metrics dashboard.
Install
npx shadcn@latest add @thrum-pro/web-analytics-dashboardThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Data shape
type WebAnalyticsDashboardData = {
kpis?: readonly {
label: string;
value: number | null;
format?: Intl.NumberFormatOptions;
delta?: number | null; // 0.124 is +12.4%
deltaLabel?: string; // "vs previous 30 days"
invert?: boolean; // a fall is good news, as for bounce rate
trend?: readonly (number | null)[];
}[];
visitors?: { labels: readonly string[]; current: readonly (number | null)[]; previous?: readonly (number | null)[] };
live?: { data: readonly { time: number; value: number | null }[]; window?: number }; // time in ms
pages?: readonly { name: string; value: number | null; href?: string }[];
sources?: readonly { name: string; value: number | null; color?: string }[];
traffic?: { rows: readonly string[]; columns: readonly string[]; values: readonly (readonly (number | null)[])[] };
devices?: readonly { name: string; value: number }[];
};{
kpis: [{ label: "Visitors", value: 48210, delta: 0.124, deltaLabel: "vs previous 30 days" }],
visitors: { labels: ["1 Nov", "2 Nov"], current: [1610, 1702], previous: [1480, 1555] },
live: { data: [{ time: 0, value: 38 }, { time: 2000, value: 41 }], window: 60000 },
pages: [{ name: "/pricing", value: 8120 }, { name: "/docs", value: 6410 }],
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | Required | The heading of the dashboard. It also names the dashboard's region. |
data | WebAnalyticsDashboardData | Required | The figures to draw, one key per section. A key left out is a section not drawn. See the type above. |
paused | boolean | Default false | Freeze the live chart's slide and show the word “Paused”, and stop the loading shimmer. Stop your live feed at the same time. |
headingLevel | 1 | 2 | 3 | 4 | 5 | Default 2 | Level of the dashboard's heading. Each section's heading is one level below it. |
periods | readonly { value: string; label: string }[] | – | Time ranges offered in the header. Leave it out, or pass fewer than two, to hide the control. |
period | string | – | The selected range, when the parent holds it. Use it with onPeriodChange. |
defaultPeriod | string | – | The range selected at first, when the control holds it itself. |
onPeriodChange | (period: string) => void | – | Called with the new range. Answer it by passing the data for that range; the dashboard does not fetch or filter anything itself. |
actions | ReactNode | – | Buttons at the end of the header row, such as a pause control for the live chart. |
loading | boolean | Default false | Draw every section, with or without data, as a skeleton of its size, and mark the dashboard busy. |
locale | string | Default "en-US" | Locale for every number on the dashboard. |
sound | boolean | Default true | Let the parts make their sounds, if the visitor has sound on. Set it to false to silence the whole dashboard. |
className | string | – | Sets the size. The layout follows the width of the dashboard itself, so it also works in a narrow column. |
Motion and sound
Motion
- First view: the cards fade in and rise 8 px one after another, 40 ms apart. Headline numbers appear at once, both visitor lines and the live line are drawn left to right, the page bars and source segments grow, the heatmap cells fade in and the device ring sweeps round. All of it ends within about 1.5 s.
- New data or a new time range: every number rolls and every chart moves to its new values together, in about 400 ms with no overshoot.
- Live: each new sample slides the live line one step to the left. Nothing moves between samples, and nothing moves while paused.
- The layout never animates. Cards keep their size while their contents change.
- Reduced motion: everything appears complete and changes instantly; the live line steps to each new sample without sliding. The demo stops its feed.
Sound
- The dashboard has no sounds of its own. Its parts play theirs, if the visitor has sound on.
- A soft click when the time range changes or a legend item is pressed, one short tone when the headline numbers land on new values, and a tick as a chart cursor moves from point to point.
- Nothing plays when the dashboard first appears, and nothing plays for a live sample.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The dashboard is a region named by its title. Each card is a section with a heading one level below the title; the headline numbers have a heading for screen readers only.
- Every chart keeps its own spoken cursor and hidden data table. The traffic sources and the live chart are images whose labels state their readings.
- The live chart is not a live region, so a changing count does not flood a screen reader. A feed that runs longer than five seconds needs a pause control: put one in actions and pass paused.
- The layout is one column when the dashboard is narrow, two from 42rem and a wide card beside a narrow one from 64rem, measured on the dashboard itself. The reading order is the same in all three.
- Under frosted glass each card turns translucent; nothing inside paints a solid block over it.
- The words “Time range”, “This period”, “Previous period” and the section names are English and fixed in this version; change them in the file.
| Keys | Action |
|---|---|
| Tab | Move through the time range, the actions, the visitors legend and chart, the top pages, the device ring and the heatmap, in reading order. |
| ← → | On the time range: pick the next range. On a chart: move the cursor one point. |
| Enter / Space | On a legend item: show or hide that line. On “Show all”: list every page. |
| Home / End | On the time range or a chart: jump to the first or last. |
| Esc | On a chart: hide the cursor. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/web-analytics-dashboard.tsx- Packages
- None
- Brings along
- Dashboard foundationsBar listCategory barDonut chartHeatmapLine chartLive chart
Changelog
- 1.0.0 · 2026-12-03First release.