Skip to content
RefineUI

Input OTP

One-time password code input field.

Overview

Machine-readable contract from Component Spec.

component: input-otpexport: InputOTPversion: 1attributes: data-refineui=input-otp

Anatomy

Partdata-refineui
rootinput-otp
slotinput-otp-slot

Variants

AxisValues
sizesm, md, lg

Accessibility

SlotElementRole
input-otpdivgroup

Keyboard

KeyActionNative
ArrowLeftprevious-trigger
ArrowRightnext-trigger

Layout

PropertyValue
directionlogical
rtltrue
npm install @refineui/react @refineui/tokens
import { InputOTP, InputOTPSlot } from "@refineui/react";
<InputOTP maxLength={6} value={code} onValueChange={setCode}>
<InputOTPSlot index={0} />
<InputOTPSlot index={1} />
<InputOTPSlot index={2} />
<InputOTPSlot index={3} />
<InputOTPSlot index={4} />
<InputOTPSlot index={5} />
</InputOTP>
<InputOTP
maxLength={4}
pattern={/\d/}
size="lg"
aria-label="Enter verification code"
/>
PropDefaultTypeDescription
valuestringControlled OTP string.
defaultValuestringUncontrolled initial value.
onValueChange(value: string) => voidEvent handler when value changes.
maxLengthnumberNumber of slots (required).
pattern/\d/RegExpPer-character allowlist (default: digits only).
size"md""sm" | "md" | "lg"Control size tier.
disabledfalsebooleanDisables interaction.
autoFocusfalsebooleanAuto-focus on mount.
aria-labelstringAccessible name for the control.
PropDefaultTypeDescription
indexnumberZero-based slot index (required).