Skip to Content
ComponentsOTP

OTP

One-time password input with individual slot elements. Auto-advances on type, handles Backspace, fires onComplete when all slots are filled. Supports alphanumeric mode.

Preview

Anatomy

import { OTP } from '@wire-ui/react' <OTP.Root length={6} onComplete={(code) => console.log(code)}> <OTP.Slot index={0} /> <OTP.Slot index={1} /> <OTP.Slot index={2} /> <OTP.Separator /> <OTP.Slot index={3} /> <OTP.Slot index={4} /> <OTP.Slot index={5} /> </OTP.Root>

Root props

PropTypeDefaultDescription
lengthnumberrequiredTotal number of slots
valuestringControlled value
defaultValuestring''Initial value for uncontrolled use
onChange(value: string) => voidCalled on every change
onComplete(value: string) => voidCalled when all slots are filled
disabledbooleanfalseDisables all slots
alphanumericbooleanfalseAllows letters in addition to digits

Slot props

PropTypeDescription
indexnumberWhich slot this element represents (0-based)

Root data attributes

AttributeWhen present
data-completeAll slots are filled
Last updated on

MIT License © 2026 wire-ui