Skip to content

Mini Cart Dropdown

Bootstrap 5 navbar mini cart dropdown with quantity steppers, remove buttons, free-shipping progress, live subtotal and checkout button.

Also known as: cart dropdown, shopping cart popup, header cart preview, ecommerce cart widget

Mini Cart Dropdown live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A Bootstrap 5 mini cart that opens from a pill-shaped cart button in the navbar and lists the products, quantity steppers, a free-shipping progress bar, the subtotal and Checkout / View cart buttons. Use it in online store headers where shoppers want a quick look at their cart without leaving the page.

How it works

The root is div.mc-shop, which holds a navbar and a sample hero. The cart sits in .dropdown.mc-cart outside the collapsing links, so it stays visible on phones. The .mc-cart__toggle button uses Bootstrap's dropdown with data-bs-auto-close="outside", so clicks on the quantity buttons do not close the menu, and data-bs-display="static" so the CSS places .mc-menu under the right edge of the button. Below 576px the menu stretches across the navbar.

Each product is an li.mc-item with data-price and data-qty. The script listens for clicks on .mc-list: buttons with data-mc-step="-1" or data-mc-step="1" change the quantity, and .mc-item__remove deletes the row. After every change render() recalculates the line prices, the .mc-badge count, .mc-menu__count, .mc-subtotal and the .mc-ship progress bar, formatting money with Intl.NumberFormat. When the last item is removed, .mc-empty appears and .mc-btn-checkout is disabled. The badge plays a short mc-bump animation on each change.

Customization

  • --mc-accent, --mc-accent-hover and --mc-accent-soft in .mc-shop: recolor the badge, checkout button, progress bar and hover states.
  • --mc-menu-width in .mc-shop: make the dropdown panel wider or narrower on larger screens.
  • data-mc-free-shipping="120" on .mc-shop: change the free-shipping threshold; set it to 0 and remove .mc-ship to hide the progress bar.
  • data-mc-currency="USD" on .mc-shop: switch to EUR, GBP or any ISO currency code for all prices.
  • data-max on an .mc-item: limit how many units of that product can be added (the default is 9).
  • data-mc-autoshow on .mc-shop: opens the dropdown on page load for the demo; remove it so the cart starts closed.
  • max-height: 19rem in .mc-list: show more rows before the item list scrolls.
  • The .mc-item__thumb--sage, --clay and --sand icon tiles: replace them with img elements for real product photos.

Use cases

  • Online store headers: shoppers check the cart, change quantities or remove items without leaving the page
  • Free-shipping promotions: the progress bar shows how much more is needed
  • Fast checkout flows: Checkout and View cart buttons right in the dropdown

Accessibility

The cart button has aria-expanded (managed by Bootstrap), aria-controls and an aria-label that the script keeps in sync, for example "Shopping cart, 4 items"; the visual badge is aria-hidden. Each stepper is a role="group" with a product-specific label, and the minus button is disabled at quantity 1. Changes are announced through the visually hidden .mc-status live region. When a row is removed, focus moves to the next remove button or to the cart heading, so keyboard users never lose their place. Bootstrap adds Escape and arrow-key support to the dropdown. Focus rings use --mc-accent, and the badge animation and progress transition are off with prefers-reduced-motion: reduce.

Usage notes

Requires Bootstrap 5 with its JS bundle and Bootstrap Icons. Replace the click handler logic with calls to your cart API and re-run the rendering after the response.

Mini Cart Dropdown 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
Shopping Carts
License
Free for personal and commercial use

Questions about this template

Can I use the Mini Cart Dropdown 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">
Mini Cart Dropdown – free Bootstrap 5 shopping cart template
Mini Cart Dropdown · free Bootstrap 5 shopping cart template

More Shopping Carts

Cart with Saved for Later Section – free Bootstrap 5 shopping cart template

Cart with Saved for Later Section

Bootstrap 5 cart page with product photos, quantity selects, a saved for later list and a live order summary with free-shipping progress.

Shopping Cart Page – free Tailwind CSS shopping cart template

Shopping Cart Page

Tailwind CSS shopping cart with quantity steppers, remove buttons, free shipping progress bar, promo code field and a live-updating order summary.

Free Shipping Progress Bar for Shopify – free Shopify shopping cart template

Free Shipping Progress Bar for Shopify

A Shopify section with a progress bar showing how far the cart is from free shipping, kept in sync with cart changes, with empty, below and reached messages.