Skip to content

Product Card with Rating and Quantity

Bootstrap 5 product card with sale badge, star rating, price, quantity stepper and add-to-cart feedback.

Also known as: ecommerce product card, product tile with add to cart, shop item card, product card with star rating

Product Card with Rating and Quantity live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A Bootstrap 5 e-commerce product card with a discount badge, wishlist heart, star rating, sale price, quantity stepper and add-to-cart button. Use it in product grids, shop landing pages or featured product sections.

How it works

The card is an article.card.pc-card capped at 360px wide with rounded corners. The top area is a position-relative wrapper holding a placeholder image (card-img-top, forced to a 3:2 aspect-ratio), a badge text-bg-danger discount label and the round .pc-wish button. The card-body contains the category, title, a star row built from Bootstrap Icons, the current price and the struck-through old price, and a row with the .pc-qty input group and the .pc-add button. Below it, .pc-status stays hidden through :empty until it has text.

The script runs on DOMContentLoaded for every .pc-card. Buttons with data-qty="-1" and data-qty="1" add their value to the number input, and a clamp() helper keeps the result between the input's min and max. A change listener re-clamps typed values. Clicking .pc-add writes a message such as "2 items added to your cart." into .pc-status. Clicking .pc-wish toggles aria-pressed, swaps the icon between bi-heart and bi-heart-fill and updates the button label; the CSS turns the filled heart red with var(--bs-danger).

Customization

  • min="1" max="10" on the quantity input: change the allowed range; the script reads both values, so the stepper respects them.
  • max-width: 360px in .pc-card: make the card wider or narrower in your grid.
  • aspect-ratio: 3 / 2 in .pc-card .card-img-top: use 1 / 1 for square product shots.
  • text-bg-danger on the discount badge: change its color or remove the badge for full-price items.
  • btn-primary on .pc-add: switch to btn-dark or btn-success to match your store.
  • color: var(--bs-danger) in .pc-card .pc-wish[aria-pressed="true"] .bi: changes the color of the active wishlist heart.
  • The status text in the .pc-add click handler in script.js: replace it with a call to your own cart API.
  • width: 8.5rem in .pc-card .pc-qty: adjust the width of the quantity control.

Use cases

  • Online stores: product grids show a discount badge, sale price and old price on every item
  • Shop landing pages: visitors choose a quantity and add to cart straight from the card
  • Featured product sections: star rating and wishlist heart help highlight bestsellers
  • Wishlist features: the heart button toggles between saved and unsaved with an updated label

Accessibility

The wishlist button uses aria-pressed and an aria-label that changes between "Add to wishlist" and "Remove from wishlist". The star row is a single role="img" element labelled "Rated 4.5 out of 5". The old price includes a visually-hidden "Was" prefix so it is not read as a second price. The quantity group has role="group" with a label, and the minus and plus buttons have descriptive aria-label values. .pc-status is a role="status" live region, so the cart confirmation is announced. Native spin buttons are hidden, but the field still accepts arrow keys and typing.

Usage notes

Requires Bootstrap 5 (added automatically) and Bootstrap Icons. Repeat the article.pc-card in a Bootstrap row for a product grid; each card works independently.

Product Card with Rating and Quantity at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Product Cards
License
Free for personal and commercial use

Questions about this template

Can I use the Product Card with Rating and Quantity code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Product Card with Rating and Quantity – free Bootstrap 5 product card template
Product Card with Rating and Quantity · free Bootstrap 5 product card template

More Product Cards

Product Card with Image Zoom – free Pure CSS product card template

Product Card with Image Zoom

Pure CSS product card whose photo zooms smoothly on hover or focus, following the pointer, with rating, color swatches and price.

Product Card with Quick Actions – free Pure CSS product card template

Product Card with Quick Actions

Responsive product card grid where hover or focus reveals wishlist, quick view and add-to-cart actions, with star ratings and a native quick view dialog.

Product Card with Sale Badge and Photo – free Bootstrap 5 product card template

Product Card with Sale Badge and Photo

Bootstrap 5 horizontal product card with a corner sale ribbon, discount sticker, old and new prices, size options that recalculate savings and stock bar.

Product Card with Color Options – free Tailwind CSS product card template

Product Card with Color Options

Tailwind CSS product card with live-recoloring color swatches, a size selector with sold-out state, wishlist toggle and add to bag button.