About the shadcn/ui Input OTP Component

The Input OTP component is part of shadcn/ui — a collection of accessible, copy-paste React components built with Radix UI and Tailwind CSS. Install it with `npx shadcn@latest add input-otp` and copy it directly into your project.

Input OTP Component — Frequently Asked Questions

How do I auto-submit when the OTP is complete?

Use `onChange` to watch for when the value length equals the OTP length: `<InputOTP onChange={(val) => { if (val.length === 6) handleSubmit(val) }}>`. Trigger submission automatically.

How do I validate OTP format (numbers only)?

Use the `REGEXP_ONLY_DIGITS` pattern from `input-otp`: `<InputOTP pattern={REGEXP_ONLY_DIGITS}>`. Import it from the `input-otp` package.

How do I integrate shadcn InputOTP with React Hook Form?

The Form example shows the complete pattern using `<FormField>` with `Controller`. Use `field.onChange` with `<InputOTP onComplete={field.onChange}>`.

Input OTP Component - shadcn/ui Examples | Shadcn Store