Skip to content

OTP Field

Provides individual segmented character boxes for typing verification codes and one-time passwords, with automatic focus progression.

2.2 KB
•
Updated on August 21, 2026

This component wraps Base UI OTP Field.

Installation

Bash

Usage

Code
Code

Anatomy

Code

Features

Masked Input

OTP input with password-style bullet masking.

With Separator

OTP field divided into separated slot groups using OtpFieldSeparator.

Accessibility

  • Manages input focus automatically as characters are typed or deleted.
  • Supports pasting multi-digit OTP codes seamlessly across slots.

Keyboard Interactions

API Reference

This component is built on Base UI OTP Field. Each slot is a real <input>; order in the tree must match length on the root.

OTPField

Root component. Accepts the same props as OTPField.Root; className is merged with the default layout styles.

Use length (required) for the number of characters. The previous maxLength prop from the legacy input-otp package is not used.

OTPFieldInput

Renders one OTP character input (Base UI OTPField.Input). Slots are ordered by DOM order in the tree (no index prop).

Label the OTP control on the root (OTPField) with aria-label or a visible <label>/FieldLabel. In Base UI 1.6+, the first OTPFieldInput should inherit that field label, while subsequent slots can use aria-label (for example, Character 2 of 6).

OTPFieldSeparator

Visual separator between slot groups. Uses the design-system Separator inside OTPField.Separator for layout and accessibility.

Examples

OTP field with label
OTP field with custom sanitization
OTP field with auto validation
Alphanumeric OTP field
OTP field with placeholder hints
Masked OTP field