Back to blocks
BlockeCommerceFree

Cart Modal React component

A product with a size picker whose Add to cart opens a centered cart modal: an Added to your cart header, line items with quantity steppers, complete-the-set add-ons, a discount code field, totals and checkout, with focus trap, Escape and click-outside to close.

About the Cart Modal component

Cart Modal confirms an add to cart with a centered window instead of a drawer: the shopper sees the line they just added highlighted, the rest of their cart, a couple of add-ons that go with it and the total, then either checks out or goes back to shopping.

Open it from the cart button and the header reads Your cart; open it from Add to cart and it reads Added to your cart with a green check. A discount code field applies codes you pass in and explains when a code doesn't qualify.

When to use it

Use it on product pages where an add is a moment worth confirming, especially with a natural add-on (socks with shoes, a case with a phone).

Prefer a mini cart or drawer on listing pages where people add many things in a row; a modal after every add slows them down.

Installation

Add the Cart Modal component to your project with the shadcn CLI. It lands in components/cart-modal.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add @reactframe/cart-modal

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install motion clsx tailwind-merge

More eCommerce components

Express Checkout Buttons
Free
Mini Cart Dropdown
Free
Multi-step Checkout Block
Free
Product List View (Rows)
Free
Accordion Checkout
Free
Masonry Product Grid
Free