StealThis .dev

Widget — Resizable widget card frame

A reusable dashboard widget card frame for a fictional ops workspace — each card carries a title, subtitle, an S/M/L size toggle that smoothly re-spans the grid, a body slot with an inline-SVG chart (area line, channel bars, or plan-mix donut), a KPI headline with an up/down delta chip, and a synced-status footer. A keyboard-friendly overflow menu opens a popover with Refresh, Expand, and Remove; refresh swaps in fresh data behind a spinner, expand lifts the chart into a modal, and cards drag to rearrange. Pure vanilla, no chart libraries.

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

Code

Resizable widget card frame

A drop-in widget shell for building dashboards. Every card shares the same anatomy — a header with title and subtitle, an S/M/L size toggle, a ⋯ overflow menu, a flexible body slot, and a status footer — so a board can mix metrics, bars, and donuts while staying visually consistent. The demo wires three live instances for the fictional Northwind Ops workspace: net revenue as an area-line trend, orders by channel as bars, and plan mix as a labelled donut, each rendered as inline SVG with no chart libraries.

The size toggle re-spans the card across the CSS grid (one column, two columns, or a taller two-column block) with a smooth transition, and the layout reflows to two columns, then a single column with off-canvas navigation as the viewport narrows. The overflow menu is a true popover: it traps arrow-key navigation, closes on Escape or an outside click, and restores focus to its trigger. Refresh drops a spinner over the body, then animates in fresh figures and a recolored delta chip; Expand lifts the chart into an accessible modal dialog with a meta strip; Remove fades the card out of the board.

Cards are draggable to rearrange, the page-level date range nudges every widget at once, and the revenue trend ticks on a timer so the board feels live (respecting prefers-reduced-motion). Controls are keyboard-operable with visible focus rings, regions use landmark roles, and the whole thing stays within a neutral product-UI palette and the project type scale.