CSC Design System next
VueFlavour Vue React Angular TypeScript PrimaryCSC UI ColorsPrimarySecondaryAccentCustom ColorsRedOrangeGreenBluePurplePink
Guides Getting started Customization Data visualization Migration guide Componentsc-accordionc-alertc-autocompletec-badgec-buttonc-button-groupc-cardc-checkboxc-csc-logoc-data-tablec-dividerc-iconc-icon-buttonc-inputc-linkc-listc-loaderc-login-buttonsc-login-cardc-mainc-menuc-messagec-modalc-navigation-buttonc-otp-inputc-pagec-paginationc-popoverc-progress-barc-progress-circlec-radio-groupc-selectc-side-navigationc-sliderc-spinnerc-statusc-stepsc-switchc-tablec-tabsc-tagsc-text-fieldc-toastsc-toolbarc-tooltip

<c-otp-input>

Examples

Basic
Vue React Angular TypeScript
<template>
  <div>
    <c-otp-input
      v-model="code"
      label="OTP"
      hint="Enter the 6-digit code we sent you"
    />

    <p>Code: {{ code ?? 'incomplete' }}</p>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const code = ref<string>();
</script>

API reference

<c-otp-input>

Properties

PropertyAttributeTypeDefaultDescription
elementIdelement-idstring''Id of the element
errorMessageerror-messagestring''Error message shown in place of the hint while the input is invalid
hasAutofocushas-autofocusbooleanfalseAuto focus
hideDetailshide-detailsbooleanfalseHide the hint and error messages
hinthintstring''Hint text for the input
labellabelstring''Label of the input group, shown above the digit inputs
lengthlengthnumber6Length of the OTP code
requiredrequiredbooleanfalseSet as required — shows the required marker on the label
validvalidbooleantrueSet the validíty of the input
valuevaluestring''Value of the input

Events

EventDetailDescription
changeValuenull | stringFired on every digit change with the complete code once all digits are filled, or `null` while the code is still incomplete (legacy value-change event). Also dispatched as `change-value` — bind that name in Vue templates.
completionnull | stringFired when the last digit is filled, carrying the complete code.
inputvoidNative bubbling input event for plain `v-model`; carries no detail — the model value is mirrored onto the host's `value` property.
update:valuestringFired on every digit change with the currently entered digits (v-model contract).

Slots

SlotDescription
defaultFallback content for the group label when the `label` prop is not set

CSS parts

Style from outside with c-otp-input::part(name) — parts are the library's only styling customization API.

PartDescription
rootThe wrapper laying out the label, the digit inputs and the message
labelThe group label rendered above the digit inputs
digitsThe inline-grid wrapper around the digit inputs
inputEach single-digit `<input>` box (one per digit)