StealThis .dev

Shop — Price + Discount Display

A precise money UI primitive for storefronts that renders every pricing variant: a bold current price, compare-at strikethrough with an auto-calculated percent-off badge, per-unit math, interest-free installments, member pricing, and low-stock or price-drop notes. Four product cards demonstrate regular, on-sale, sold-out, and pre-order states. A currency switcher reformats and re-rounds every figure live, a member-price toggle swaps rates, and a flash-sale button flips a card between sale and regular pricing.

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

Code

Price + Discount Display

A compact, self-contained price primitive built for clean white storefronts with a single green accent. Four product cards cover the pricing states you actually ship: a regular in-stock item, an on-sale item with a compare-at strikethrough and a calculated percent-off badge, a sold-out item with a muted price and notify action, and a pre-order with an installment plan and ship date. Each card layers the supporting money copy — per-unit price, interest-free installments, member price, and a price-drop note — on top of a gradient product tile with an inline-SVG silhouette, star rating, and stock chip.

Every figure is computed in vanilla JS from a single USD source value, so the display stays consistent. The currency switcher re-rates and re-rounds all prices, units, installments, badges, and drop notes to USD, EUR, GBP, or JPY (yen drops the decimals). The member-price toggle swaps in member rates, tags the affected prices, and recalculates the percent-off badge from the new effective price. The flash-sale demo button flips the mug set between its sale and regular pricing, showing and hiding the strikethrough, badge, drop note, and low-stock chip in sync.

All interactions are real: thousands grouping, decimal handling per currency, badge math derived from compare-at versus current price, and toasts confirming add-to-cart, reserve, and notify actions. The layout collapses to a single column under 360px and every control is keyboard-usable with visible focus rings.

Illustrative storefront UI only — fictional products, prices, and reviews. No real checkout.