docs/en-US/component/input-otp.md
Used to enter a one-time password (OTP).
:::demo
input-otp/basic
:::
The length of the input fields can be customized by setting the length prop.
:::demo
input-otp/custom-length
:::
There are three types available: outlined (default), filled, and underlined.
:::demo
input-otp/types
:::
There are three sizes available: large, default, and small.
:::demo
input-otp/sizes
:::
Disabled and readonly states are supported.
:::demo
input-otp/disabled
:::
Use the mask prop to hide the input characters.
:::demo
input-otp/mask
:::
Customize the separator between OTP fields.
:::demo
input-otp/separator
:::
Set the validator prop to validate the input character, and use inputmode to specify the keyboard type.
:::demo
input-otp/validator
:::
| 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](char: string, index: number) => boolean | () => true |
| inputmode | Native inputmode attribute | ^[string] | — |
| type | The type of the OTP fields | ^[enum]'outlined' | 'filled' | 'underlined' | 'outlined' |
| size | The size of the OTP fields | ^[enum]'large' | 'default' | 'small' | '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]() => string | VNode | — |
| 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] | — |
| Name | Description | Type |
|---|---|---|
| update:modelValue | Triggers when value updates | ^[Function](value: string) => void |
| change | Triggers when the value changes after input blur | ^[Function](value: string) => void |
| finish | Fires when all fields have been filled | ^[Function](value: string) => void |
| focus | Triggers when input is focused | ^[Function](event: FocusEvent) => void |
| blur | Triggers when input is blurred | ^[Function](event: FocusEvent) => void |
| Name | Description | Type |
|---|---|---|
| separator | The separator between OTP fields | ^[object]{ index: number } |
| Name | Description | Type |
|---|---|---|
| inputRefs | HTML input elements array | ^[object]Ref<(HTMLInputElement | undefined)[]> |
| focus | Focus an OTP input field | ^[Function](index?: number) => void |
| blur | Blur the focused OTP input field | ^[Function]() => void |