Skip to content
↑↓ to navigate↵ to openesc to close

Menu

OTP Input

Preview

Enter 123456 to verify.

Install

Add it with your package manager, or copy the source manually.

Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide

bunx --bun shadcn-vue@latest add @beui-vue/otp-input

Import the shared styles once in your application.

TSUsage
import OTPInput from '@/components/beui/blocks/OTPInput.vue'
import '@/components/beui/styles.css'

API Reference

length?
number

Number of slots.

Default6
value?
string

Alias of `modelValue`, kept from the original port.

Default—
defaultValue?
string
Default
@update:model-value?
(value: string) => void
Default—
@complete?
(value: string) => void

Fires once every slot is filled.

Default—
label?
string

Optional label rendered above the slots.

Default—
hint?
string

Helper text shown below the slots while idle.

Default—
successMessage?
string

Message shown below the slots when status is "success".

Default—
errorMessage?
string

Message shown below the slots when status is "error".

Default—
status?
OTPStatus

External validation feedback. "error" shakes, "success" draws a check.

Defaultidle
mask?
boolean

Render dots instead of the typed digits.

Defaultfalse
disabled?
boolean
Defaultfalse
autoFocus?
boolean
Defaultfalse
aria-label?
string

Accessible label for the underlying input.

Default—
labels?
Partial<typeof otpInputMessages>

Override any built-in string.

Default—
className?
string
Default—
v-model?
string
Default—
ariaLabel?
string

Accessible label for the underlying input.

Default—
@change?
(value: string) => void
Default—
Also on React Native. Digits roll into slots, with SMS autofill.(opens in a new tab)

Updated