Skip to content

FormPin

PIN / OTP input built on Reka UI's PinInput primitive. Renders length single-character cells; user can paste a full code or type cell-by-cell. Supports mask (password dots), otp (mobile autofill from SMS), and a 'number' type for numeric-only input.

bash
npm install @vuecs/forms

Basic usage

vue
<script setup lang="ts">
import { VCFormPin } from '@vuecs/forms';
import { ref } from 'vue';

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

<template>
    <VCFormPin v-model="code" :length="6" type="number" otp />
</template>
css
@import "tailwindcss";
@import "@vuecs/design";

@import "@vuecs/forms";

@custom-variant dark (&:where(.dark, .dark *));

Props

PropTypeDefaultDescription
modelValuestring[] | number[] | nullundefinedBound value array; element type matches type prop
lengthnumber6Number of cells rendered
type'text' | 'number''text'Input mode + element type of modelValue
placeholderstring''Per-cell placeholder character
maskbooleanfalseRender values as <input type="password"> (dots)
otpbooleanfalseSet autocomplete="one-time-code" for mobile SMS autofill
disabledbooleanfalseDisable interaction
requiredbooleanfalseForm-required attribute
namestringundefinedForm-submission name
idstringundefinedRoot id
themeClassPartial<FormPinThemeClasses>undefinedPer-instance theme override
themeVariantRecord<string, string | boolean>undefinedPer-instance variant values

Events

EventPayloadDescription
update:modelValuestring[] | number[]Emitted on every cell change
completestring[] | number[]Emitted when every cell is filled

Released under the Apache 2.0 License.