StealThis .dev

Product Card

E-commerce product card with image, quick-add to cart, wishlist toggle, discount badge, color swatch picker, and rating stars. Pure CSS + JS.

Open in Lab
css vanilla-js
Targets: JS HTML

Code

Product Card

A polished e-commerce product card with hover-reveal quick-add button, wishlist heart toggle, sale badge, color swatch selector, star rating display, and a cart count feedback animation.

Features

  • Product image with overlay “Quick Add” button revealed on hover
  • Wishlist heart button with filled/empty toggle animation
  • Sale/discount badge (e.g., “20% OFF”)
  • Color swatch selector with active ring indicator
  • Star rating (0–5 half-star support) with review count
  • “Add to Cart” with a brief cart icon bounce success state
  • Multiple card variants: standard, horizontal, minimal

How it works

  1. Image ::after overlay transitions from opacity: 0 to 1 on .card:hover
  2. Heart button toggles data-wishlisted attribute + CSS .active for fill animation
  3. Swatch clicks update data-selected and the displayed image alt/gradient
  4. Add-to-cart animates a cart icon via CSS @keyframes bounce for 600 ms