Home Components Input OTP
React OTP Input Components
10 free React OTP inputs built with Tailwind CSS and shadcn/ui conventions. Copy the code or install with the shadcn CLI. Great for one-time codes, verification, and PIN entry.
Input OTP 1 : Four separate digit-only OTP boxes, centred under an Enter OTP label.Input OTP 2 : Four-digit code input with a 30 second countdown that enables a Resend link when it ends.Input OTP 3 : Four-character code input that accepts both letters and numbers, with a case-insensitive tip.Input OTP 4 : Joined four-slot code input on a muted background with a Resend link underneath.Input OTP 5 : Four spaced grey OTP boxes where the active slot grows slightly and gets a ring when focused.Input OTP 6 : Four-digit OTP input with a shield icon heading and smaller rounded boxes that highlight on hover.Input OTP 7 : Six-digit OTP input split into two joined groups of three with a dash between them.Input OTP 8 : Underline-style OTP input with no boxes, where a primary line animates under each slot.Input OTP 9 : Six-digit OTP with two groups of three separately spaced grey boxes divided by a long dash.Input OTP 10 : Compact six-slot code input with small boxes and a dot separator between the two halves.
About React OTP Input Components A React OTP input is a row of boxes for entering a one-time code, like a 6-digit login or verification code. Watermelon UI OTP inputs are built on the input-otp library with Tailwind CSS, so paste, autofill, and keyboard navigation work across the slots. Add one with the shadcn CLI, then set maxLength and handle the finished code in onComplete or onChange.
When to use it Email or SMS verification during sign-up. Two-factor authentication codes at login. Short PINs or invite codes with a fixed length. When to use something else Use Input Mask when the value is longer or has a mixed pattern like a card number. Use Form when the code is one field among several that need schema validation. Frequently asked questions How do I allow only numbers in the OTP input? Pass pattern={REGEXP_ONLY_DIGITS}, imported from input-otp. Use REGEXP_ONLY_DIGITS_AND_CHARS to allow letters too.
How do I submit the code automatically when it is complete? Use the onComplete callback, which fires once every slot is filled. Call your verify function from there instead of waiting for a button.
How do I use the shadcn OTP input with react-hook-form? Render InputOTP inside a Controller and pass field.value to value and field.onChange to onChange. input-otp calls onChange with the whole code as a string, so a zod rule like z.string().length(6) validates it.
Does the OTP input support paste and SMS autofill? Yes. input-otp renders one transparent input over the slots, so pasting a full code fills every slot. It sets autocomplete to one-time-code by default, which lets phones suggest codes from SMS.
How to use React OTP Input Components Start from a React project with Tailwind CSS and shadcn/ui set up. Next.js, Vite, Remix, and Astro all work. Run npx shadcn@latest add https://registry.watermelon.sh/r/input-otp-1.json to add the source files to your project. Import it where you need it, then edit the Tailwind classes and design tokens to match your product. Dependencies installed with it: input-otp, react-icons.
The code is yours: it lives in your repository, so there is no runtime package to keep updated. Watermelon UI is free and open source under the MIT license.
More: Free React components , UI library alternatives , guides .