StealThis .dev

Shop — Mini-cart Flyout

A polished e-commerce mini-cart drawer that flies in from the right when you add a product. It packs slide-in line items with thumbnails, quantity steppers, and per-line totals, a live free-shipping progress bar, a running subtotal, and view-cart plus secure-checkout actions. Built with vanilla JS, it features a focus trap, Escape and overlay dismissal, an animated badge, recompute-on-change totals, and a friendly empty state.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

Mini-cart Flyout

A clean storefront with a six-product grid where every card has a CSS-gradient “product photo”, star rating, review count, and prominent price. Pressing Add on any item bumps the cart badge, slides the new line into a right-hand drawer, and animates a free-shipping progress bar toward the $75 threshold — a staple e-commerce conversion pattern.

Inside the drawer, each line shows a thumbnail, title, unit price, a working quantity stepper, and a per-line total. Adjusting quantity or removing an item recomputes the subtotal and the shipping bar in real time, and items animate out on removal. Once the cart empties, a friendly empty state replaces the list and footer.

The drawer is a proper modal dialog: it opens with a focus trap, closes on Escape, the overlay click, or the close button, restores focus to the cart button, and announces cart changes through an aria-live region. Everything is keyboard-usable with visible focus rings, and the layout collapses gracefully down to ~360px.

Illustrative storefront UI only — fictional products, prices, and reviews. No real checkout.