Components / Inputs
OTP Input
A one-time-code input with popping digits, a blinking caret, paste and SMS autofill support.
Enter the 6-digit code we sent you
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/otp-input.tsx. - 3
Use it
example.tsximport { OtpInput } from "@/components/ui/otp-input"; export default function OtpInputDemo() { return ( <div className="text-center"> <p className="mb-4 text-sm text-zinc-600 dark:text-zinc-400">Enter the 6-digit code we sent you</p> <OtpInput /> </div> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| length | number | 6 | Number of digits. |
| onComplete | (code: string) => void | — | Called when every digit is filled. |