bloxa

OTP Input

FREE

One-time code field with slots, grouping, masking, paste and SMS autofill support.

Playground

Change the props and watch the component and its code update live.

Props
Code
import { OtpInput } from "@/components/ui/otp-input";

<OtpInput
  groupSize={3}
  onComplete={(code) => verify(code)}
/>

Installation

Terminal
npx @bloxa/cli add otp-input
# or: npx shadcn@latest add @bloxa/otp-input

Examples

Verification code

Codes can be pasted and autofilled from SMS. onComplete fires when every slot is filled.

Enter the 6-digit code we sent you.

Grouped and masked

API reference

Every component also accepts the props of the element it renders.

OtpInput

PropTypeDefaultDescription
lengthnumber6Number of characters.
value / defaultValuestring—Code value.
onValueChange(value: string) => void—Called on every change.
onComplete(value: string) => void—Called when every slot is filled.
pattern"numeric" | "alphanumeric""numeric"Accepted characters.
groupSizenumber—Separator after every N slots.
maskbooleanfalseHides characters behind dots.
size"md" | "lg""md"Slot size.