
Inputs · €7
OTP input
A one-time code input with paste, resend timer and error states.
Pay once on Gumroad: the download, plus a licence key for the registry and the MCP server.
Details
- Category
- Inputs
- Plan
- Paid, €7 once
- Code
- React + Tailwind, TypeScript · 326 lines
- Files
- OtpInput.tsx
- Needs
- The Bot (installed with it)
- Agents
- MCP server and shadcn registry
About
A one-time-code card with the Bot (StackD Kit 01) on top. Its eyes follow the box you're typing in. Paste a code (or tap the phone's "code from Messages/Mail" suggestion) and the digits drop in one after another. When the last box is filled it checks by itself: the boxes ripple while the Bot glances from one end of the row to the other.
Right code: the boxes turn green one by one, the Bot gets happy eyes and hops. Wrong code: the row shakes, the boxes get a red ring, the Bot looks down (a little sadder with every miss) and the whole code is selected, so the next digit you type starts over. A countdown, then Resend.
Under the boxes there is one real <input> (autocomplete="one-time-code"), so autofill, paste, password managers, screen readers and mobile number pads all work. White and black versions. React + Tailwind, no other libraries. Respects reduced motion.
Install
Once: add the StackD registry to components.json, with the licence key from your receipt in STACKD_LICENSE_KEY (in .env.local):
"registries": {
"@stackd": {
"url": "https://www.stackd.codes/r/{name}.json",
"headers": { "X-License-Key": "${STACKD_LICENSE_KEY}" }
}
}With the shadcn CLI:
npx shadcn@latest add @stackd/otp-inputOr let your agent add it through the StackD MCP server:
claude mcp add --transport http stackd https://www.stackd.codes/mcpPrompt for your agent
Paste it into Claude Code, Cursor, Codex or VS Code once the MCP server is connected.
Add the StackD OTP input component to this project. Use the StackD MCP server: call get_component with { "name": "otp-input" }, write the files at the paths it gives and install any npm packages it lists. Then use it where it fits, following its README for the props, and keep its own styles. It is a paid component: if the server says it needs a licence, tell me where to buy it.Use
- Copy
OtpInput.tsxandBot.tsxinto the same folder of your project (for examplecomponents/).
If you already have the Bot from an earlier StackD component, replace it with this one.
- Check the code in
onComplete. Returntrue(or a promise oftrue) when it's right:
import { OtpInput } from './components/OtpInput'
<OtpInput
sentTo="ana@company.com"
onComplete={async (code) => {
const res = await fetch('/api/verify', { method: 'POST', body: JSON.stringify({ email, code }) })
if (res.ok) router.push('/app')
return res.ok
}}
onResend={() => fetch('/api/send-code', { method: 'POST', body: JSON.stringify({ email }) })}
/>
A 4-character code with letters, shown as dots, in black:
<OtpInput length={4} type="alphanumeric" mask theme="dark" />
In Next.js the files already start with 'use client'. In other React setups that line does nothing.
Options
| Prop | Default | What it does |
|---|---|---|
onComplete | (code) => boolean | Promise<boolean>. Called as soon as every box is filled (or on Enter) | |
onResend | Called by the Resend link. The countdown starts again and the boxes empty | |
length | 6 | How many characters |
type | 'numeric' | 'numeric' or 'alphanumeric' (letters are uppercased). Other characters are ignored |
resendIn | 30 | Seconds before Resend is available. 0 = straight away |
sentTo | Shown in the subtitle: "We sent a 6-digit code to …" | |
title | 'Check your email' | |
doneTitle | "You're verified" | The title once the code is right |
mask | false | Dots instead of the characters |
split | true for even lengths of 6+ | A small gap in the middle (3 · 3) |
theme | 'light' | 'light' (white) or 'dark' (black) |
bot | pill, tall eyes | { shape, eyes } for the Bot, from Kit 01 |
compact | false | No title, smaller Bot, for tight spaces |
If onComplete throws, it counts as a wrong code. Without onComplete, the right code is 482913 (handy for trying it out; replace it before you ship).
Colours from StackD
White #FFFFFF · Ink #141310 · Wine #901919 · Olive #6C8544 · Ochre #BE9344 · Lilac #C9B8FF
Licence
You can use it in personal and commercial projects. Don't resell or share the component on its own.
Made by StackD · stackd.codes




