Form
InputOtp
One box per character of a one-time code, that moves along as you type and fills at once from a paste or autofill.
WAI-ARIA tested
Import
main.ts
import { InputOtp } from '@vitral/vue';Basic
Try pasting 123456.
Masked
Sizes and states
API
Read from packages/vue/src/components/InputOtp/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| length | number | How many characters the code has. Defaults to 4. |
| integerOnly | boolean | Accept digits only, and ask for the numeric keyboard. |
| mask | boolean | Hide the characters as a password box does. |
| size | Size | — |
| variant | InputVariant | Defaults to the plugin's `inputVariant`. |
| invalid | boolean | — |
| disabled | boolean | — |
| readonly | boolean | — |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| change | event: { originalEvent: Event; value: string } | — |
| complete | event: { originalEvent: Event; value: string } | Every box holds a character. |
| focus | event: FocusEvent | — |
| blur | event: FocusEvent | — |
Slots
| Name | Slot props | Description |
|---|---|---|
| default | (props: { index: number | Replaces a box. The events wire it up; `attrs` carries its name and state. |
| value | string | — |
| attrs | Record<string, unknown> | — |
| events | { input: (event: Event) => void; keydown: (event: KeyboardEvent) => void; paste: (event: ClipboardEvent) => void; focus: (event: FocusEvent) => void } | — |