InputOTP
InputOTP collects a one-time code, with one slot per character. Use it for verification and sign-in codes. For other short text, use Input.
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Composition
Examples
With separator
Split a six-digit code into two groups of three with a separator.
Disabled
Dim every slot and block input while the field is disabled.
Props
InputOTP
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | No default documented |
|
InputOTPGroup
InputOTPGroup adds no props of its own; it accepts the props of the element or primitive it wraps.
InputOTPSeparator
InputOTPSeparator adds no props of its own; it accepts the props of the element or primitive it wraps.
InputOTPSlot
| Prop | Type | Default | Description |
|---|---|---|---|
indexRequired | number | No default documented | Position of the slot in the code, starting at 0. |
InputOTP collects a one-time code, with one slot per character. Use it for verification and sign-in codes. For other short text, use Input.
Installation
Install the following dependencies:
Copy and paste the following code into your project.
components/input-otp/InputOTP.vue components/input-otp/InputOTPGroup.vue components/input-otp/InputOTPSeparator.vue components/input-otp/InputOTPSlot.vue components/input-otp/index.ts lib/icons.ts Keep each file at the path shown above it.
Paths are relative to
packages/vue/src/. Keep the same folders under your@/root, and the imports between files work without edits.
Usage
Examples
With separator
Split a six-digit code into two groups of three with a separator.
Disabled
Dim every slot and block input while the field is disabled.
Props
InputOTP
| Prop | Type | Default | Description |
|---|---|---|---|
defaultValue | string | No default documented | No description |
modelValue | string | No default documented | No description |
InputOTPGroup
InputOTPGroup adds no props of its own; it accepts the props of the element or primitive it wraps.
InputOTPSeparator
InputOTPSeparator adds no props of its own; it accepts the props of the element or primitive it wraps.
InputOTPSlot
| Prop | Type | Default | Description |
|---|---|---|---|
indexRequired | number | No default documented | Position of the slot in the code, starting at 0. |