Display UI

Input OTP

Specialized input fields for entering one-time passwords or multi-digit codes, typically used in authentication flows.

Loading...

Installation

npx shadcn@latest add https://display-ui.vercel.app/r/InputOTP

Usage

import { InputOTP } from "@/components/display-ui/InputOTP"
<OTPInput length={4} disabled={false} autoFocus={false} />

API

Input Props

For OTPInput Component

AttributeTypeDescriptionDefault
lengthnumberNumber of OTP input boxes to render.4
onComplete(otp: string) => voidCallback fired when all OTP digits are filled. Receives the complete OTP string.-
valuestringControlled value for the OTP input. When provided, the component becomes controlled.-
autoFocusbooleanAutomatically focuses the first empty OTP input on mount.true
disabledbooleanDisables all OTP input fields.false
containerClassNamestringAdditional CSS classes applied to the OTP container.-
inputClassNamestringAdditional CSS classes applied to each OTP input field.-
ariaLabelstringAccessible label describing the OTP input group."One-time passcode"

Examples

Four Boxes

Loading...

Six Boxes

Loading...

Credits

This component is inspired by Rehman Kalawant Design Shared On Github.

On this page