OTP Field

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

<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

mirrored code: 123

Enter the code from your message.
Enter the six-digit code sent to your email.

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 6/12/2026