StealThis .dev

Widget — Global filter + date-range bar

A sticky global filter bar for analytics dashboards, built for the fictional Northwind Pulse commerce workspace. It pairs a Today/7d/30d/Custom date-range control with multi-select dropdowns for channel, region and status, plus a debounced search box. Every choice renders as a removable colour-coded chip with a live active-filters count and clear-all. Applying filters re-renders four KPI cards with deltas and inline-SVG sparklines, an animated orders-by-day bar chart and a results table — all vanilla JS, no libraries.

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

Code

Global filter + date-range bar

A self-contained dashboard filter bar for the fictional Northwind Pulse commerce analytics workspace. The bar pins to the top of the scroll area (gaining a deeper shadow once it sticks) and groups three controls: a segmented date-range picker with Today / 7d / 30d / Custom presets that reveals two <input type="date"> fields, a debounced search box that matches order IDs, customers and channels, and a trio of multi-select dropdowns for Channel, Region and Status.

Each selection becomes a removable, colour-coded chip below the bar; an “active filters” count and a Clear all button appear as soon as anything is set, and each dropdown button shows its own selected-count badge. Removing a chip, toggling a checkbox, or clearing all re-runs a single apply() render: a results summary updates in an aria-live region, four KPI cards (orders, revenue, average order value, refund rate) count up to new values with up/down deltas and hand-drawn SVG sparklines, an orders-by-day bar chart animates to its new heights, and the recent-orders table re-filters with a graceful empty state.

Everything is vanilla JS with no dependencies. Data is seeded pseudo-randomly so renders are stable, a live tick injects a fresh fictional order every few seconds, dropdowns close on outside-click and Escape, and the layout collapses the sidebar to an icon rail and the grid to a single column below 720px while staying usable down to 360px. Controls are keyboard-operable with focus-visible rings and labelled for screen readers.