Skip to content

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.

Also known as: sale product card, discount product card, deal of the day card, flash sale product card, product card with ribbon

Product Card with Sale Badge and Photo live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A Bootstrap 5 product card for discounted items: a large product photo with a diagonal "Sale" ribbon and a round discount sticker, next to the old and new prices, a savings pill, size options, a stock bar and an add-to-cart button. Use it for flash sales and deal-of-the-day blocks.

How it works

The root is an article.card.sbp-card with a Bootstrap row g-0. On phones the photo sits on top as a square; from the md breakpoint the card turns horizontal and the .sbp-img fills the left half with object-fit: cover. The .sbp-media wrapper holds two absolutely positioned elements: .sbp-ribbon, a band rotated by -45 degrees across the top-left corner, and .sbp-badge, a dashed circle that shows the discount percentage.

The right column contains the category, title, star rating, the sale price in .sbp-new, the struck-through original price inside an s.sbp-old element and the .sbp-save pill. The case-size buttons are Bootstrap .btn-check radios styled as .sbp-option; each carries a data-price and a data-old-price. A Bootstrap .progress bar shows how much of the sale stock is left.

The script runs on DOMContentLoaded for every .sbp-card. Its update() function reads the checked radio, formats the prices with Intl.NumberFormat, calculates the amount saved and the rounded percentage, and writes them into .sbp-new, .sbp-old-value, .sbp-save-value and .sbp-badge-value. Clicking .sbp-add writes a confirmation into .sbp-status. Without JavaScript the card still shows the correct prices for the default option.

Customization

  • data-price and data-old-price on each .btn-check: set the prices per variant; the savings and the badge percentage are recalculated automatically.
  • --sbp-sale in style.css: changes the color of the ribbon, the sticker, the sale price and the stock bar.
  • --sbp-ink and --sbp-bg: set the text color, the selected option and button color, and the card background.
  • Remove .sbp-ribbon or .sbp-badge from .sbp-media if you want only one sale marker.
  • width: 20% in .sbp-stock-fill together with aria-valuenow and aria-valuetext on .sbp-stock-bar: show the real remaining stock.
  • max-width: 52rem in .sbp-card: make the card wider or narrower.
  • The message in the .sbp-add click handler of script.js: replace it with a call to your cart API.

Use cases

  • Flash sales: a diagonal Sale ribbon and a round discount sticker highlight reduced items
  • Deal-of-the-day blocks: old and new prices with a savings pill show the offer clearly
  • Online stores: size options recalculate prices and the saved amount
  • Limited-stock offers: a stock bar shows how much of the sale stock is left
  • Product pages: a horizontal card with a large photo and an add-to-cart button

Accessibility

The card is an article labelled by its heading. The ribbon is decorative and hidden with aria-hidden="true", while the sticker and both prices carry visually-hidden prefixes ("Discount", "Sale price", "Original price"), so screen readers announce them in context. The original price uses the semantic s element. Size options are native radios inside a fieldset with a legend, operable with arrow keys and with a clear focus outline. The star row is a single role="img" with a text label, the stock bar exposes aria-valuetext, and .sbp-status is a polite live region. The photo zoom on hover is turned off under prefers-reduced-motion: reduce.

Usage notes

Requires Bootstrap 5 (added automatically) and Bootstrap Icons. The product photo comes from Unsplash; replace it with your own image. For several cards on one page give each one unique id and radio name values.

Product Card with Sale Badge and Photo 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 Sale Badge and Photo 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 Sale Badge and Photo – Bootstrap 5 product cards component screenshot
Product Card with Sale Badge and Photo · Bootstrap 5 Product Cards

More Product Cards

Product Card with Image Zoom – Pure CSS product cards preview

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 – Pure CSS product cards preview

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 Color Options – Tailwind CSS product cards preview

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.