Skip to content

OTP Input

Form

One-time password input with individual digit fields and auto-advance.

Six digitsGrouped slotsCompletion feedback
Open preview

Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.

Usage

Compose InputOTPGroup and InputOTPSlot for each index. Set maxLength and a digit pattern for numeric codes. Verification must happen in your backend.

Import
import {
  InputOTP,
  InputOTPGroup,
  InputOTPSlot,
  InputOTPSeparator,
} from "@dashboardpack/core/components/ui/input-otp";

Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.

API reference

Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.

OTP Input props
PropType / DefaultDescription
maxLengthnumber

Default: required

Number of accepted characters.
value / onChangestring / (value: string) => void

Default: —

Control the entered code.
patternstring

Default: —

Accepted character pattern.
index (InputOTPSlot)number

Default: required

Zero-based character position.
disabledboolean

Default: false

Disable code entry.

Build with these too