OTPInput

A one-time password input with individual digit boxes, auto-advance, and paste support.

Live Demo

Props

PropTypeDefaultDescription
lengthnumber6Number of digit boxes.
valuestringControlled value string.
onChange(value: string) => voidCallback receiving the full digit string.
disabledbooleanfalseDisables all inputs.
errorstringError message shown below the inputs.
autoFocusbooleanfalseAuto-focuses the first box on mount.

Usage

import { OTPInput } from '@ghiberti85/ui'

// 6-digit default
<OTPInput onChange={(val) => console.log(val)} />

// 4-digit PIN
<OTPInput length={4} />

// With error
<OTPInput error="Invalid verification code" />

// Controlled
const [code, setCode] = useState('')
<OTPInput value={code} onChange={setCode} />

View in Storybook

Open in Storybook
Ghiberti UI — Design System