Pho Design System

OTP Field

A one-time-code input — a row of single-character cells with paste, arrow-key navigation, and auto-advance. Built on Base UI OTPField, it defaults to numeric input and autocomplete="one-time-code" so a texted code can be filled in one tap.

Import

import { OtpField } from "@photon-ai/pho-ui/components/otp-field";

Basic

Set length for the number of cells. Give the field an aria-label (or an external <label>) — a bare row of boxes is otherwise unlabeled.

<OtpField length={6} aria-label="Verification code" />

Masked

mask hides the entered characters, like a password field — reach for it when the code is sensitive and shouldn’t sit visible on screen.

<OtpField length={6} mask aria-label="Verification code" />

Controlled

Pass value with onValueChange to control the code. onValueChange fires on every edit — typing, delete, and paste — so you can read the code as it fills. For a “code is complete” moment, use onValueComplete, or set autoSubmit to submit the owning form the instant every cell is filled.

Type a code

const [code, setCode] = useState("");

<OtpField
  length={6}
  value={code}
  onValueChange={setCode}
  aria-label="Verification code"
/>;

Props

Accessibility

Keyboard:

Focus shows a 2px brand ring on the active cell (:focus-visible).

Best practices