Skip to content
Playground

OTP Field

A segmented one-time-password input with paste and keyboard support.

A segmented one-time-password input with paste and keyboard support.

Backed by Base UI OTP Field for upstream behavior and configuration. Zenos owns the public API, styling, and composition shown on this page.

TSX
import { OTPField } from "@zentara-co/zenos-ui";

Each slot uses the same surfaces as Input: default (standard), filled (subtle), and none (borderless). Set variant on the root or on individual OTPField.Input nodes when composing groups.

The root forwards disabled, required, and Field invalid semantics to every slot. Invalid styling matches Input.

Use the shorthand root when every slot is identical. Compose Group, Input, and Separator when the code has meaningful sections.

0 of 6 characters entered.

Variants

defaultfillednone
OTPField.Root
OTPField.Input
OTPField.Group
OTPField.Separator

API

PropTypeDefaultDescription
value string — Controlled OTP value.
defaultValue string — Initial uncontrolled value.
onValueChange (value: string) => void — Runs when digits change.
length number — Number of generated inputs.
disabled boolean false Disables entry.
required boolean false Marks the code as required.
variant default | filled | none default Surface treatment per slot (`default` = standard, `filled` = subtle, `none` = borderless).

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

OTPField preserves Base UI paste, focus, and keyboard behavior. Label the root through Field, set the expected length, and avoid implementing per-slot focus movement yourself. Separators are presentation-only and are hidden from assistive technology.