StealThis .dev

Widget — Drag-rearrange widget grid

A polished analytics dashboard whose widget cards reorder by dragging a handle, with a live insertion placeholder, smooth reflow, and order persisted to localStorage. A full keyboard alternative moves any focused card with the arrow keys and announces each change through an aria-live region, while a Reset layout button restores the defaults. Cards carry KPI sparklines, an inline SVG bar chart, a revenue line chart, a donut, a top-pages list, and a live-ticking traffic tile.

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

Code

Drag-rearrange widget grid

A self-contained “Northbeam Analytics” dashboard built around a reorderable widget grid. Each card exposes a grab handle, a header menu, and a small data visualization — KPI sparklines with up/down deltas, an inline SVG bar chart of signups by channel, a revenue line chart with a gradient area fill, a plan-mix donut, a ranked top-pages list, and a live traffic tile that ticks every couple of seconds. The shell uses a sidebar nav, a page header with a date-range segmented control, and a soft neutral product palette.

Dragging a card by its handle lifts it, shows a dashed insertion placeholder where it will land, and reflows the rest of the grid smoothly; dropping persists the new order to localStorage so it survives reloads. The whole grid is keyboard-operable: focus any card and press the arrow keys (or Home/End) to move it, with each move announced through a polite aria-live region for screen readers. A “Reset layout” button clears the saved order and restores the defaults.

Filters and live data are wired up too — switching the 7d / 30d / 90d range updates the KPI values and recolors their deltas (churn is treated as “lower is better”), the live tile random-walks within a plausible band and redraws its sparkline, and the sidebar collapses to an off-canvas drawer below 720px. Everything is vanilla JS with no libraries, and motion respects prefers-reduced-motion.