Animated cart drawer in a shadcn or UI-kit app: scope its CSS
The snippet above imports cart-drawer.css exactly as it ships. That's fine when the cart is the whole page, like our demo. Inside an app built on shadcn, or another kit that styles body, buttons or .grid, it leaks: the file was written as a standalone page, so it puts its colours on :root, styles html and body, and uses short global classes like .grid and .row.
We measured it on October 25, 2026 in a scratch shadcn app on Tailwind v4. Unedited, the body went near-black in Space Grotesk, shadcn's --muted took the cart's grey-blue, a grid-cols-2 row became three columns with a 30px gap, and a shadcn Button went from 14px at weight 500 to 16px at weight 400.
The fix is a small edit to your copy, shown below: wrap the file in @scope (.qcd), turn :root and html,body into :scope, delete the 9 html:not(.fit) prefixes, add three rules to globals.css, and put the cart inside a div with the class qcd. The full explanation and the before and after numbers are on the shadcn cart drawer guide ("A shadcn cart drawer for Next.js", under More for React). This page didn't measure it again.
Browser support for @scope, from MDN's compatibility data read October 25, 2026: Chrome and Edge 118+, Firefox 146+, Safari 17.4+ on Mac and iPhone. Safari 26.0 to 26.3 has a partial version that skips input and textarea elements; the cart has neither.
A browser without @scope drops the whole block, so the cart shows up unstyled there. If you need those browsers, skip the @scope wrapper and put .qcd in front of every selector instead (last file below). We haven't measured that version.
components/cart-drawer.css (your copy, three edits)
/* Your copy of cart-drawer.css from the zip. Three edits: */
/* 1. Delete every "html:not(.fit) " prefix.
There are 9, all inside the max-width: 760px block. */
/* 2. ":root{" becomes ":scope{", and "html,body{" becomes ":scope{". */
/* 3. Put the whole file inside one @scope block: */
@scope (.qcd) {
/* ...the file as shipped, with edits 1 and 2... */
}
app/globals.css (three rules for the cart)
/* Add below shadcn's theme and @layer base in app/globals.css */
/* Stack Cart Drawer was built with Tailwind's preflight off. Inside .qcd only,
roll the base styles (preflight and shadcn's base layer) back to browser
defaults. Unlayered and zero specificity, so the piece's own rules still win.
SVGs are left out: a revert would wipe their width, r, fill and stroke. */
:where(.qcd, .qcd :not(svg, svg *)) {
all: revert;
}
:where(.qcd) {
line-height: normal;
}
:where(.qcd svg) {
display: inline;
vertical-align: baseline;
}
app/shop/page.tsx (the wrapper)
// app/shop/page.tsx: wrap the cart so the scoped CSS has a root.
return (
<div className="qcd">
<StackCartDrawer /* ...the props above, unchanged... */ />
</div>
);
components/cart-drawer.css (fallback for browsers without @scope)
/* No @scope block. Keep edit 1 (delete "html:not(.fit) "), then put .qcd
in front of every selector, each part of a comma list included: */
.qcd{ /* was :root{ ...the colour and font variables... */ }
.qcd *{box-sizing:border-box}
.qcd{ /* was html,body{ ...margin, background, colour, font... */ }
.qcd .grid{ /* ...as shipped... */ }
/* ...and so on to the end of the file. The globals.css rules stay as they are. */
Install
Copy from the zipPut react/src/components + react/src/data into src/, then npm i framer-motion.
Or ask your AIPaste PROMPT.md into Cursor, Lovable or v0.
Props
data
store name, products, free-shipping threshold
onCheckout
your payment call, resolve { ok: true }
autoplayDemo
loops the demo until the first tap
How qodesign compares
qodesign vs 21st.dev21st.dev is best for: browsing a huge marketplace and copying many components a month.
qodesign vs Skiper UISkiper UI is best for: unusual interaction details for landing pages: image reveals, cursor trails, tooltips, drag-and-scroll galleries.
All comparisons, with prices read on each library's own site.
Yes, as a client component. Keep "use client" at the top of the file that renders it, as in the snippet above. App Router and Pages Router both work.
Does it take payments?
No. onCheckout hands you the items and total, and you call Stripe or your backend.
Will it change my shadcn styles?
Imported as shipped, yes. Its CSS sets --muted, the body colours and a global .grid rule, and we measured shadcn Buttons and grids changing. With the scoped copy and the three globals.css rules on this page, it stays inside its own div.
Can Cursor or v0 add it for me?
Yes. Each download has a PROMPT.md. Paste it into Cursor, Lovable, v0 or Claude Code and it fits the piece into your app.
Can I use it in client work?
Yes, in personal and client projects. You can't resell the code itself as a kit.