StealThis .dev

Pricing — Usage slider (price scales)

A usage-based pricing card with a range slider for monthly API calls that recomputes the bill in real time using tiered, stepped pricing. Dragging the slider names the current tier (Starter, Pro, Scale, Enterprise), shows included quota and per-call overage rate, and renders a base-plus-usage breakdown. A filled track with boundary tick marks, an aria-live price announcement, and a side-by-side tier reference round it out, all in vanilla JS.

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

Code

Usage slider (price scales)

A single pricing card for the fictional Northwind Cloud where the customer drags a range slider to set their expected monthly API-call volume. The price recalculates live with a tiered, stepped model: each tier (Starter, Pro, Scale, Enterprise) carries its own base fee, included quota, and per-call overage rate, so the marginal cost drops as volume grows. The big headline price bumps on change, the current tier name updates, and a base-plus-usage breakdown lists the base fee, included quota, and any overage as units × rate.

The slider has a gradient-filled track and tick marks at the three tier boundaries (50K, 250K, 750K). It exposes aria-valuenow and a descriptive aria-valuetext that includes the tier and computed price, while an aria-live region announces the new total as you drag. Crossing a tier boundary fires a small toast. A four-chip tier strip and a side panel of tier reference cards (with a “Most popular” Pro highlight) stay in sync with the slider, and both are clickable to snap the slider into that tier’s range.

Everything is vanilla JS with no dependencies: the price math, formatting (Intl.NumberFormat), tick generation, and highlight syncing run from a single tier table. Interactions are keyboard usable with focus-visible rings, the tier chips act as buttons, and the layout reflows to a single column down to ~360px.