Retents UI

Input OTP

A one-time password input with individual character slots.

Import

import {
  InputOTP,
  InputOTPGroup,
  InputOTPSlot,
  InputOTPSeparator,
} from "@retents/ui/input-otp"

Usage Guidelines

When to use

  • For entering one-time passwords, verification codes, or PIN codes that arrive via SMS, email, or authenticator apps.
  • When the input has a fixed, known length (typically 4–8 characters).

When NOT to use

  • For general text or numeric input — use Input instead.
  • For password fields — use Input with type="password".

Accessibility

Each slot is individually focusable and supports keyboard navigation. The component auto-advances to the next slot as the user types.

Preview

Usage

<InputOTP maxLength={6}>
  <InputOTPGroup>
    <InputOTPSlot index={0} />
    <InputOTPSlot index={1} />
    <InputOTPSlot index={2} />
  </InputOTPGroup>
  <InputOTPSeparator />
  <InputOTPGroup>
    <InputOTPSlot index={3} />
    <InputOTPSlot index={4} />
    <InputOTPSlot index={5} />
  </InputOTPGroup>
</InputOTP>

Peer dependencies

This component requires: input-otp

Source

On this page