StealThis .dev

Shop — Product Card

A reusable e-commerce product card shown as a four-up grid of fictional storefront items. Each card pairs a CSS-gradient and inline-SVG product silhouette with a wishlist heart, a Sale or New badge, brand and title, a star rating with review count, colour swatch dots, and a sale price with compare-at strikethrough. Hover reveals a Quick add flyout with a size picker; swatches preview the image tint, the heart toggles, and a sold-out variant shows a Notify me state. Pure vanilla JS, no images or external libraries.

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

Code

Product Card

The core commerce primitive, rendered four ways in a responsive grid. Every card is built from the same parts: a soft tinted media tile holding an inline-SVG product silhouette (shoe, tote, mug, cap), a corner badge for Sale, New, or Sold out, and a floating wishlist heart. Below the image sit the brand eyebrow, a linked title, a star rating with its review count, a row of colour swatch dots, and a prominent price — with a compare-at strikethrough and savings chip when the item is on sale.

Interactions are all real. Hovering or focusing a card slides up a Quick add flyout with a size picker; choosing a size pushes a toast and bumps the header bag badge. Swatch dots preview their colour by re-tinting the product image on hover or keyboard focus, and clicking one locks the choice in. The wishlist heart toggles with a little burst animation, and the sold-out card swaps its sizes for a keyboard-operable Notify me control instead of an Add action.

Swatch groups support arrow-key roving, controls expose aria-pressed and live regions, focus-visible rings stay sharp, and the grid collapses from four columns to two to one. On touch widths the Quick add panel stays pinned open since there is no hover, and a reduced-motion fallback disables the transitions.

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