ZBMui

OTP Field

View markdown

A one-time password input composed of individual character slots.

Installation

components/ui/otp-field.tsx

Usage

Examples

Sizes

Pass size="lg" to increase the size of the OTP field. The default size is default.

With label

Grouped separator

Alphanumeric

Use validationType="alphanumeric" for recovery, backup, or invite codes that mix letters and numbers.

Accept letters and numbers for backup codes such as A7C9XZ.

Custom normalization

Use normalizeValue to normalize accepted values before state updates, such as converting alphanumeric codes to uppercase. It runs after validationType filtering, and the result is filtered against validationType again. Use validationType="none" when the normalizer should provide the full validation rule.

Pair custom rules with inputMode for keyboard hints and onValueInvalid for rejected characters.

Digits 0-3 only.

Placeholder

<OTPFieldInput> is a real input, so native placeholder props and CSS work as usual.

Mask entry

Use mask when the code should be obscured while it is being typed.

Use mask to obscure the code on shared screens.

ZBMui

Built by the ZBM.

© 2026 ZBM ui. All rights reserved.