# Product Card

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

- Category: [CSS Cards](https://copy-css.com/category/cards)
- Tags: ecommerce, shop, add to cart, wishlist, rating, price
- Live preview: https://copy-css.com/snippets/product-card
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```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

```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;
}
```

## Notes

- 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.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
