InputOtp beta
Used to enter a one-time password (OTP).
Basic Usage
Custom Length
The length of the input fields can be customized by setting the length prop.
Types
There are three types available: outlined (default), filled, and underlined.
Sizes
There are three sizes available: large, default, and small.
Disabled & Readonly
Disabled and readonly states are supported.
Mask
Use the mask prop to hide the input characters.
Separator
Customize the separator between OTP fields.
Custom Validation
Set the validator prop to validate the input character, and use inputmode to specify the keyboard type.
API
Attributes
| Name | Description | Type | Default |
|---|---|---|---|
| model-value / v-model | The value of the OTP fields. Since numbers must not have leading zeros, modelValue is allowed to be a number only during initialization. | string / number | undefined |
| length | The OTP fields length | number | 6 |
| validator | Custom validator function | Function | () => true |
| inputmode | Native inputmode attribute | string | — |
| type | The type of the OTP fields | enum | 'outlined' |
| size | The size of the OTP fields | enum | 'default' |
| mask | Whether to enable password mode | boolean | — |
| disabled | Whether the OTP fields are disabled | boolean | undefined |
| separator | The separator between OTP fields | string / VNode / Function | — |
| validate-event | Whether to trigger form validation | boolean | true |
| readonly | Same as readonly in native input | boolean | false |
| id | Native id attribute | string | — |
| aria-label a11y | Native aria-label attribute | string | — |
Events
| Name | Description | Type |
|---|---|---|
| update:modelValue | Triggers when value updates | Function |
| change | Triggers when the value changes after input blur | Function |
| finish | Fires when all fields have been filled | Function |
| focus | Triggers when input is focused | Function |
| blur | Triggers when input is blurred | Function |
Slots
| Name | Description | Type |
|---|---|---|
| separator | The separator between OTP fields | object |
Exposes
| Name | Description | Type |
|---|---|---|
| inputRefs | HTML input elements array | object |
| focus | Focus an OTP input field | Function |
| blur | Blur the focused OTP input field | Function |