StealThis .dev

Widget — KPI / stat row (with trends)

A copy-paste KPI strip of five stat cards for a fictional SaaS — new sign-ups, revenue, active users, churn and NPS — each pairing a big tabular value with a coloured delta chip, an up or down arrow, a vs-last-period caption and a tiny inline-SVG sparkline that tracks the trend. A Today / Week / Month toggle swaps every value, delta and sparkline with an ease-out count-up, a live toggle nudges the figures every few seconds, and a channel-mix bar gives the row a data-dense companion. Pure HTML, CSS and vanilla JavaScript, no chart libraries.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

A clean, responsive row of five KPI cards for Meridian Labs, a fictional SaaS. Each card shows a label, a large tabular-number value, a pill-shaped delta with an up or down arrow coloured with --ok or --danger, a “vs last period” caption, and a tiny inline-SVG sparkline whose shape and colour follow the trend. Churn is treated as an inverse metric, so a falling value reads as good (green) while a rising one recolours its delta and sparkline red — the row encodes meaning, not just direction.

The primary interaction is the Today / Week / Month period toggle. Selecting a range swaps the entire dataset: every value animates with an ease-out count-up to its new figure, deltas recompute and recolour, captions update to the matching comparison, and each sparkline redraws to fit its new series. A live toggle nudges the current-day figures every few seconds with a subtle flash so the strip feels alive, the card menus (⋯) fire a toast, and a stacked channel-mix bar beneath the row updates alongside the period for a data-dense companion widget.

Everything is built with semantic landmarks, aria-selected tabs with roving arrow-key navigation, an aria-pressed live toggle, visible focus rings and WCAG-AA contrast. The grid flows from five columns to three, two, then a single column by ~360px, animations respect prefers-reduced-motion, and live updates pause when the tab is hidden. No frameworks, no chart libraries, no build step.