Skip to content
On this page

CodeInput

The code input used for Two Factor Authentification.

Basic Usage

Use fields property to set input cells

<template>
  <div class="flex flex-col items-center justify-center bg-gray/40 py-5">
    <HcCodeInput
      v-model="value"
      :fields="6"
    />
    <div class="mt-2 h-3">
      {{ value }}
    </div>
  </div>
</template>

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

const value = ref('');
</script>

Props

PropertyType Values Description Default
modelValueStringStringbinding valuefalse
fieldsNumberNumberset number of empty fields (code length)6
filterKeysString[]String[]list of filtered keyboard keys[ "Minus", "Period" ]
filterCharsString[]String[]list of filtered chars[ "-", "." ]
filterCharsIsWhitelistBooleanBooleanuse filterChars array as whitelistfalse
autocompleteBooleanBooleansame as autocomplete in native inputundefined
forceUppercaseBooleanBooleantransform output value to uppercasefalse
type StringStringnative 'type' attributetext

Events

PropertyType Values Description Default
update:model-valueFunctionvalue - stringtriggers when the CodeInput value changes
completeFunction-triggers when input fullfilled
focusFunctionevent - FocusEventtriggers when CodeInput focuses
blurFunctionvalue - stringtriggers when CodeInput blurs

Created by DeepVision Software.