Skip to content

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
  • @complete fires 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. name submits the joined code with the form.
  • separators splits a long code where the sender does (123 456); masked hides it from people nearby; numeric=false for letter codes.

Usage ​

ts
import { BlessInputOTP } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
idstring—id of the first cell; inside a BlessField it takes the field's
namestring—submitted with the form as the joined code
lengthnumber6
numericbooleantruedigits only (inputmode numeric) or any char
separatorsnumber[][]indexes after which to render a separator
disabledboolean—
invalidboolean—
labelstring—
maskedboolean—
modelValuestring""

Events

NamePayloadDescription
update:modelValue[value: string]
complete[code: string]

Released under the MIT License. Character names and artwork belong to their owners.