Using the animated OTP input in a shadcn app: scope its CSS
The OTP input looks right on its own page, but step-up-gate.css isn't written to share a page with a UI kit. We imported it as shipped into a shadcn new-york-v4 test page on Tailwind 4.3.3 on October 25, 2026. The body went near-black and switched to Space Grotesk, the primary Button's label turned dark on its dark fill, Buttons went from 14px/500 to 16px/400 and bg-muted changed colour.
Why: the colour tokens live on :root (two of them, --muted and --font-mono, share names with shadcn and Tailwind), html, body and button get styled directly, and generic classes like .card, .grid and .ring are global. It's all unlayered, so Tailwind's layered utilities lose to it.
Make four edits to your copy and give the gate a class. Your page sits inside the gate as children, so put it in a div with the class otp-backdrop and the rules stop at that div.
.root has to become :scope as well: inside @scope a plain .root doesn't match the root element, and without it the card fell 540px down our test page. The rename matters because custom properties inherit into your page. bg-background text-foreground font-sans on the otp-backdrop div give your page back what it used to get from body. @keyframes shake stays global, so rename it if your app has its own.
After the edits, the shadcn Button, Card, Input, grid, bg-muted strip and link measured the same as on a page without the gate, both outside it and as the page behind it, in headless Chromium 156, Firefox 157 and WebKit 27.2 at 1280 and 390 px. The gate itself only changed at its root, which now carries the dark background and overflow-x: clip html and body used to. The shake still plays. We tested static markup with the real CSS, not the running component.
@scope support, from MDN's compatibility data read October 25, 2026: Chrome and Edge 118+, Firefox 146+, Safari 17.4+. Safari 26.0 to 26.3 has a partial version that skips input elements, and the code cells are inputs, so they'd show as plain fields there. Browsers without @scope drop the whole block. For those, prefix every selector in your copy with .qd-otp instead and move the :root variables onto .qd-otp. That version has no lower edge, so the button reset reaches your page inside the gate, and we haven't measured it.
components/step-up-gate.css (the edits)
/* components/step-up-gate.css (your copy from the zip). Four edits: */
/* 1. Find "html:not(.fit) " and replace it with nothing (33 places,
all inside the max-width: 760px block). */
/* 2. Change ":root{", "html,body{" and ".root{" to ":scope{". */
/* 3. Replace "--muted" with "--otp-muted" and "--font-mono" with
"--otp-font-mono" everywhere in the file (10 places each). */
/* 4. Wrap the whole file in one @scope block: */
@scope (.qd-otp) to (.otp-backdrop) {
/* ...the file as shipped, with edits 1 to 3... */
}
the gate (wrapper)
<StepUpGate className="qd-otp" /* ...the same props as above... */>
{/* the scope stops at this div; the classes give your page its body styles back */}
<div className="otp-backdrop bg-background text-foreground font-sans">
<BillingPage />
</div>
</StepUpGate>
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.
Not if you scope it. As shipped, step-up-gate.css turns a shadcn app dark, switches fonts and breaks Buttons. With the four edits and the qd-otp class on this page, the shadcn parts we measured stayed the same.
Does the OTP gate work in Next.js?
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 support SMS autofill?
It shows a "From Messages" chip with the code you pass as autofillCode, the way iOS suggests it.
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.