Skip to content
Velkin LogoVelkin Logo
Velkin
VELKIN/UI

Modern UI components for product teams and their AI agents. Lit core, typed wrappers, live MCP.

sales@velkinui.com

Product

  • Docs
  • Components
  • Studio
  • Pricing

Resources

  • Quick start
  • Blog
  • Changelog
  • Roadmap
  • Status

Project

  • About
  • Contact
  • License
  • Privacy
  • Terms

© 2026 Velkin. MIT core · Pro licenses available.

VELKIN

Otp

An OTP input component with segmented fields, paste support, and validation.

vu-otp · @velkin/react/otp

Copy page

Import

React
npm i @velkin/react

import { VuOtp } from "@velkin/react/otp";

Examples

API

Props

PropTypeDefaultDescription
namestring—Form field name for submit (`name` attr).
defaultvaluestring—Restored on `<form reset>` (`defaultvalue` attr).
formidstring—External `<form>` id (`formid` attr).
disabledboolean—Non-interactive; blocks cell entry (`disabled` attr).
readonlyboolean—Focusable but cannot change cells (`readonly` attr).
requiredboolean—Blocks valid submit when incomplete (`required` attr).
requiredmessagestring—Custom `valueMissing` message (`requiredmessage` attr).
labelstring""Plain-text label; slotted `label` wins when assigned.
hintstring""Helper text; `hint` slot wins when assigned.
idstring""Host id for label `for` / `aria-*` wiring.
variantVuOtpVariant"default"Field chrome recipe. Default: `"default"`.
toneVuOtpTone"normal"Neutral surface weight. Default: `"normal"`.
sizeVuOtpSize"md"Cell scale. Default: `"md"`.
radiusVuOtpRadius"md"Corner preset (`none`/`sm`/`md`/`lg`/`full`). Default: `md`.
blockbooleanfalseStretches the cell row to the container width. Default: `false`.
compactbooleanfalseTighter label/hint/error spacing. Default: `false`.
lengthnumber6Number of OTP characters. Default: `6`.
alphanumericbooleanfalseAllows letters in addition to digits. Default: `false`.
valuestring""Canonical OTP string (unmasked). Default: `""`.
maskedbooleanfalseMasks cell glyphs (`type="password"`). Default: `false`.
showerrorsboolean—Shows validation after activation (`showerrors` attr). Default: `false`.
validationactiveboolean—Drives invalid styling after activation (`validationactive` attr). Default: `false`.
invalidbooleanfalseTrue when last validation found errors (`invalid` attr). Default: `false`.
incompletemessagestring—Error when some cells are filled but not all; empty uses default.
arialabelstring—Names the row when no visible label is present.
incompleteMessagestring""Error when some cells are filled but not all; empty uses a default.
ariaLabelstring""Names the row when no visible label is present.
showErrorsbooleanfalseShows validation after activation.
validationActivebooleanfalseDrives invalid styling after activation.

Events

EventDetailDescription
vu-changeVuOtpChangeDetailCommitted value change (`detail.value`).
vu-invalidVuOtpInvalidDetailWhen validation messages are recomputed.
vu-clearVuOtpClearDetailAfter `reset()` syncs from `defaultValue`.

Slots

SlotDescription
labelRich label markup; takes precedence over string `label` when assigned.
hintOptional helper copy (HTML); overrides string `hint` when assigned.
errorReplaces default validation message list when assigned.

CSS parts

PartDescription
fieldColumn stacking label, cells row, hint, and error.
labelLabel element above the OTP row.
cellsFlex row wrapping all digit cells (`role="group"`).
cellOne OTP character input.
hintNeutral helper text under the row.
error-messageRegion for `slot="error"` or stacked default validation lines.
error-lineOne default validation string when `slot="error"` is empty.
textString `label` text when the `label` slot is empty.

Methods

MethodDescription
reset- Clears cells to `defaultValue` and dispatches `vu-clear`.
focusFirst- Focuses the first OTP cell.
validateInput- Runs validators and syncs validity.

Types

NameDefinition
VuOtpChangeDetail
{ value: string; }
VuOtpClearDetail
{ value: string; }
VuOtpInvalidDetail
{ errors: string[]; }
VuOtpRadius
"sm" | "md" | "lg" | "none" | "full"
VuOtpSize
"sm" | "md" | "lg"
VuOtpTone
"subtle" | "normal" | "strong"
VuOtpVariant
"outline" | "default" | "underline"

Related

Inputs

  • Advanced FilterAn advanced filter component with expression input and visual builder.
  • ButtonA clickable button component with multiple variants and states.
  • Button GroupA button group component with shared styling and optional selection.
  • CheckboxA checkbox component with label, hint, and validation.
  • Checkbox GroupA checkbox group component with shared label and validation.
  • Color AreaA two-dimensional color picker component for saturation and brightness.

Guides

  • FormsFormData, VuForm, and validation
  • EventsonVu* / v-model / e.detail
  • Appearancevariant, color, tone, size

Browse

  • Previous: InputEarlier in the sidebar
  • Next: Radio GroupLater in the sidebar
  • All componentsBrowse the full index