Free and open-source React verification code input components built for modern applications and websites. These verification code inputs are built using Input OTP and styled with Tailwind CSS.
Installation
You can add this verification code input component using our CLI or manually:
npx untitledui@latest add pin-input
Verification code input examples
Below are examples and variations of this verification code input component:
API reference
Import the parts and assemble them:
import { PinInput } from "@/components/base/input/pin-input"; <PinInput> <PinInput.Label /> <PinInput.Group maxLength={4}> <PinInput.Slot index={0} /> <PinInput.Slot index={1} /> <PinInput.Separator /> <PinInput.Slot index={2} /> <PinInput.Slot index={3} /> </PinInput.Group> <PinInput.Description /> </PinInput>
HintText
Import HintText from @/components/base/input/hint-text. Renders React Aria’s Text — all of its props are supported.
Props from React Aria Components (2)
Also accepts all standard HTML attributes, all aria-* attributes, all standard React DOM event handlers.
PinInput
Renders a <div> element.
Also accepts all standard HTML attributes, all aria-* attributes, all standard React DOM event handlers.
PinInput.Description
Renders HintText.
Props from React Aria Components (2)
Also accepts all standard HTML attributes, all aria-* attributes, all standard React DOM event handlers.
PinInput.Group
Renders OTPInput.
Props from input-otp (11)
Also accepts all standard input attributes, all standard HTML attributes, all aria-* attributes, all standard React DOM event handlers.
PinInput.Label
Import Label from @/components/base/input/label. Renders React Aria’s Label — all of its props are supported.
Props from React Aria Components (4)
Also accepts all standard HTML attributes, all aria-* attributes, all standard React DOM event handlers.
PinInput.Label
Renders Label.
Props from React Aria Components (4)
Also accepts all standard HTML attributes, all aria-* attributes, all standard React DOM event handlers.
PinInput.Separator
Renders a <div> element.
Also accepts all standard HTML attributes, all aria-* attributes, all standard React DOM event handlers.
PinInput.Slot
Renders a <div> element.
Also accepts all standard HTML attributes, all aria-* attributes, all standard React DOM event handlers.
FAQs
Please refer to our frequently asked questions page for more.
It's built on Input OTP, so install input-otp along with the component, as shown in the manual installation steps.
Set maxLength on PinInput.Group (it defaults to 4) and render one PinInput.Slot per digit, each with an index starting at 0.
Pass a pattern to PinInput.Group. The examples use REGEXP_ONLY_DIGITS from input-otp, as in pattern={REGEXP_ONLY_DIGITS}.
PinInput.Group passes its props to Input OTP's OTPInput, so use value and onChange for a controlled input and onComplete to run code, such as submitting the form, once every slot is filled.
Set size on the PinInput root to "xxxs", "xxs", "xs", "sm", "md" or "lg". The default is "md".
Set disabled or invalid on the PinInput root. Unlike the React Aria based inputs, these props are named disabled and invalid, not isDisabled and isInvalid.
Place PinInput.Separator between two slots, for example after the third slot of a six-digit code as in the with separator example. It renders a dash with role="separator".