InputOTP
One-time code cells
For a code the user is sent — by SMS, email or an authenticator app — and types back once. Not for a password or a PIN they choose; that is PasswordInput.
Basic
code: — · try 123456 · paste works
@completefires when every cell is filled, so the form can submit itself.- Paste anywhere and SMS autofill (the first cell is
autocomplete="one-time-code") spread across every cell. - Inside a Field the label points at the first cell and the field's error reaches every cell.
namesubmits the joined code with the form. separatorssplits a long code where the sender does (123 456);maskedhides it from people nearby;numeric=falsefor letter codes.
Usage
ts
import { BlessInputOTP } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
id | string | — | id of the first cell; inside a BlessField it takes the field's |
name | string | — | submitted with the form as the joined code |
length | number | 6 | |
numeric | boolean | true | digits only (inputmode numeric) or any char |
separators | number[] | [] | indexes after which to render a separator |
disabled | boolean | — | |
invalid | boolean | — | |
label | string | — | |
masked | boolean | — | |
modelValue | string | "" |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: string] | |
complete | [code: string] |