Zephora UI

Form

InputOTP

One-time-code input rendered as N single-character cells with paste distribution, autofill support and full keyboard navigation.

Import

import { InputOTP } from "@zephora/react";

Examples

Basic

Six cells by default; paste a whole code into any cell.

Length and mask

`length` controls the cell count; `mask` obscures entered characters.

Controlled with completion

`onComplete` fires once the code reaches `length` characters.

Typed: —

API

InputOTP props

PropTypeDefaultDescription
lengthnumber6Number of characters in the code.
valuestringControlled code value.
defaultValuestring""Initial code value (uncontrolled).
onValueChange(value: string) => voidCalled with the code on every edit.
onComplete(code: string) => voidCalled once the code reaches length characters.
maskbooleanfalseObscures entered characters (renders password inputs).
disabledbooleanfalseDisables every cell.
invalidbooleanfalseMarks the code invalid: sets aria-invalid and error styling.
unstyledbooleanfalseHeadless mode — drops Zephora classes so your own CSS can style it.
…restHTMLAttributes<HTMLDivElement>Forwarded to the group wrapper element.

Keyboard

KeyAction
0-9 / charactersFills the cell and advances focus.
BackspaceClears the cell, or moves back and clears the previous one.
Arrow Left / Arrow RightMoves focus between cells.
Home / EndFocuses the first / last cell.
PasteDistributes the pasted code across cells.