Skip to content

OtpInputProps

"aria-describedby"?: string;

id(s) of external error/help text.


"aria-label"?: string;

autoComplete?: string;

The attribute that unlocks iOS/Android SMS suggestions.

'one-time-code'

autoFocus?: boolean;

blurOnComplete?: boolean;

Blur the input once complete (dismisses the mobile keyboard).

false

children?: ReactNode;

className?: string;

defaultValue?: string;

Uncontrolled initial value. Ignored when value is provided.


dir?: "ltr" | "rtl";

disabled?: boolean;

id?: string;

Base id; slots derive ${id}-slot-0, …


inputRef?: Ref<HTMLInputElement>;

Ref to the underlying <input>.


invalid?: boolean;

Sets aria-invalid and data-invalid.


label?: string;

Accessible name for the field.


length?: number;

Number of slots. Positive integer.

6

mask?: string | boolean;

Render a mask char instead of the value (sensitive codes). true -> ’•’.


mode?: OtpMode;

Drives inputMode, pattern, autoCapitalize.

'numeric'

name?: string;

Posts natively in a <form> and is the name RHF/Formik bind to.


nonce?: string;

CSP nonce applied to any injected style.


onBlur?: (event) => void;

Fires when focus leaves the whole control, never between slots.

ParameterType
eventFocusEvent<HTMLInputElement>

void


onChange?: (value) => void;

Emits the sanitized string (not an event).

ParameterType
valuestring

void


onComplete?: (value) => void;

Fires once the value reaches length. The only completion hook — the library never calls form.requestSubmit() for you; wire submit/verify here.

ParameterType
valuestring

void


pasteTransform?: (pasted) => string;

Clean pasted text before distributing.

ParameterType
pastedstring

string

strips whitespace and - . _ separators


pattern?: string | RegExp;

Override the allowed-character test (per char). Beats mode when set.


placeholder?: string;

Per-slot placeholder shown while empty.


readOnly?: boolean;

render?: (ctx) => ReactNode;

Tier 3 escape hatch. Ignored when children are provided.

ParameterType
ctxOtpRenderContext

ReactNode


required?: boolean;

slotInteraction?: OtpSlotInteraction;

‘spatial’ = tap any slot to edit it (auto-degrades to ‘crush’ on iOS, which cannot fully hide ::selection); keyboard input always takes precedence over deferred pointer placement. ‘crush’ = collapsed-input behaviour everywhere.

'spatial'

style?: CSSProperties;

transform?: (value) => string;

Normalize each committed value (e.g. s => s.toUpperCase()). Applied after pattern.

ParameterType
valuestring

string


value?: string;

Controlled value. Sanitized to allowed chars and clamped to length; never throws.


webOTP?: boolean;

Opt into the WebOTP API (Android Chrome): programmatic SMS retrieval + AbortController cleanup. Layered on top of autocomplete, never instead of it.

false