OTP Input
A one-time code input, with a slot per character.
MarkdownExamples
Basic
complete fires once every slot is filled, so the code can be checked without a submit button.
Try 123456.
Groups
Letters and digits
API
| Prop | Type | Default |
|---|---|---|
labelVisible label, linked to the control. | string | — |
hintHelp text under the control, announced as its description. | string | — |
error
| string | boolean | — |
lengthNumber of characters in the code. | number | 6 |
type
| "alphanumeric" | "numeric" | "numeric" |
groupSizePuts a separator after every this many slots, e.g. | number | — |
optionalAppends the | boolean | false |
disabledDisables the control. | boolean | false |
idId for the control; generated with | string | — |
modelValueThe code typed so far. | string | "" |
| Event | Payload |
|---|---|
completeEvery slot is filled, by typing, pasting or autofill. | [code: string] |
update:modelValue
| [value: string] |
| Slot | Props |
|---|---|
separatorContent between groups. Defaults to a dash. | — |
Styling
- Parts
fieldfield-labelfield-optionalotpotp-inputotp-slototp-caretotp-separatorfield-message- States
data-field-errordata-otp-focuseddata-otp-disableddata-otp-activedata-otp-filleddata-field-tone
Accessibility
- It's one native input with
autocomplete="one-time-code", so codes from SMS and password managers fill in, and screen readers announce a single field. - Pasting a whole code fills every slot; spaces and dashes in it are dropped.
- The slots are hidden from screen readers, which read the input's value instead.