CSS Product Card

An e-commerce product card with an image, wishlist button, star rating, price and add-to-cart button.

  • ecommerce
  • shop
  • add to cart
  • wishlist
  • rating
  • price
HTML
<article class="shop-card">
  <div class="shop-card-media">
    <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 25'%3E%3Crect width='40' height='25' fill='%23e0e7ff'/%3E%3Crect x='14' y='7' width='12' height='14' rx='2' fill='%236366f1'/%3E%3Cpath d='M17 8V6a3 3 0 0 1 6 0v2' fill='none' stroke='%234338ca' stroke-width='1.4'/%3E%3C/svg%3E" alt="Indigo canvas tote bag" width="200" height="125">
    <button class="shop-card-wish" type="button" aria-label="Add to wishlist">
      <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 20.5 4.1 12.8A5 5 0 0 1 12 6.6a5 5 0 0 1 7.9 6.2Z"/></svg>
    </button>
  </div>
  <div class="shop-card-body">
    <h3><a href="#">Canvas Tote</a></h3>
    <p class="shop-card-rating"><span aria-hidden="true">★</span> 4.8 <span>(212 reviews)</span></p>
    <div class="shop-card-foot">
      <strong>$48</strong>
      <button type="button">Add to cart</button>
    </div>
  </div>
</article>
CSS
.shop-card {
  width: 200px;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 6px 20px -8px rgba(0, 0, 0, 0.15);
  color: #1c1917;
  font-family: system-ui, sans-serif;
}

.shop-card-media {
  position: relative;
}

.shop-card-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 8 / 5;
  object-fit: cover;
}

.shop-card-wish {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #e11d48;
  cursor: pointer;
}

.shop-card-wish svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.shop-card-wish:hover svg {
  fill: currentColor;
}

.shop-card-body {
  padding: 12px 14px 14px;
}

.shop-card h3 {
  margin: 0;
  font-size: 15px;
}

.shop-card h3 a {
  color: inherit;
  text-decoration: none;
}

.shop-card-rating {
  margin: 2px 0 10px;
  font-size: 12px;
}

.shop-card-rating span:first-child {
  color: #f59e0b;
}

.shop-card-rating span:last-child {
  color: #78716c;
}

.shop-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shop-card-foot strong {
  font-size: 18px;
}

.shop-card-foot button {
  padding: 7px 12px;
  border: 0;
  border-radius: 8px;
  background: #1c1917;
  color: #fff;
  font: 600 13px system-ui, sans-serif;
  cursor: pointer;
}

.shop-card-foot button:hover {
  background: #44403c;
}

.shop-card a:focus-visible,
.shop-card button:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

About this CSS Product Card

This CSS Product Card is 106 lines of pure CSS (1.6 KB) with no JavaScript and no dependencies. It uses box shadows, CSS Grid, Flexbox and aspect-ratio. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #fff
  • #1c1917
  • #e11d48
  • #f59e0b
  • #78716c
  • #44403c
  • #6366f1

How to use this product card

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .shop-card class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback