OTP Field

An OTP field lets users enter a one-time passcode across multiple single-character inputs.

On this page
<OTPField length={6}>
  <Label>Verification code</Label>
  <div className="flex items-center">
    <Group>
      <Input />
      <Input aria-label="Digit 2" />
      <Input aria-label="Digit 3" />
    </Group>
    <OTPFieldSeparator className="px-2 text-fg-muted">-</OTPFieldSeparator>
    <Group>
      <Input aria-label="Digit 4" />
      <Input aria-label="Digit 5" />
      <Input aria-label="Digit 6" />
    </Group>
  </div>
</OTPField>

Installation

npx shadcn@latest add @dotui/otp-field

Usage

Use OTPField with Group and the existing Input component to compose passcode slots.

import { OTPField } from '@/components/ui/otp-field'
import { Label } from '@/components/ui/field'
import { Group } from '@/components/ui/group'
import { Input } from '@/components/ui/input'
<OTPField length={6}>
  <Label>Verification code</Label>
  <Group>
    <Input />
    <Input aria-label="Digit 2" />
    <Input aria-label="Digit 3" />
    <Input aria-label="Digit 4" />
    <Input aria-label="Digit 5" />
    <Input aria-label="Digit 6" />
  </Group>
</OTPField>

Examples

Basic OTP Field

Verification Form

Enter the six-digit code sent to your email.

2FA Verification

Two-factor authentication

Enter the code from your authenticator app.

Email Verification

Verify your email

We sent a code to jane@acme.com

The code expires in 10 minutes.

API Reference

OTPField

An OTP field lets users enter a one-time passcode across multiple single-character inputs.

PropType
boolean
boolean
boolean
union
number
boolean
function
OTPValidationType
string
string
function

OTPFieldSeparator

A separator visually divides groups of inputs within the OTP field.

PropType
Orientation

Last updated on 7/1/2026