OTP Input

A one-time-code field drawn as separate slots, with paste and SMS autofill.
Stable
Web
iOS
Android
@advui/core
Source

Basic

Enter the 6-digit code we sent you.

Installation

pnpm
pnpm add @advui/core
npm
npm install @advui/core

Usage

import { Field, OtpInput } from '@advui/core'

<Field label="Verification code">
  <OtpInput onComplete={verify} />
</Field>

Examples

Grouped and invalid

That code has expired.

API reference

OtpInput

Also accepts Input props such as `aria-label`, `autoFocus` and `name`.
PropTypeDefaultDescription
lengthnumber6Number of characters.
valuestring—The code typed so far.
defaultValuestring—Starting `value` when uncontrolled.
onValueChange(value: string) => void—Called on every change.
onComplete(value: string) => void—Called once every slot is filled.
type'numeric' | 'alphanumeric''numeric'Which characters are kept; others are dropped.
groupSizenumber—Draws a dash after every N slots.
size'sm' | 'md' | 'lg''md'Slot size.
invalidbooleanfalseError styling and `aria-invalid`.
disabledbooleanfalseNot focusable or editable.

Accessibility

  • It is one text box, so screen readers announce one field and its whole value, not six.
  • Give it a label with a Field or aria-label; the slots are hidden from assistive technology.
  • Pasting a full code, or picking it from the SMS suggestion, fills every slot at once.
Keyboard interactions
KeyAction
CharactersFill the next slot.
BackspaceClears the last slot.

Platform notes

Web
autocomplete="one-time-code" lets browsers offer codes from SMS.
iOS
textContentType="oneTimeCode" shows the code from Messages above the keyboard.
Android
autoComplete="sms-otp" lets autofill offer the code from SMS.
Since v0.5.0Last updated Nov 2, 2026Edit this page on GitHub