1.0.4 • Published 5 months ago

vue3-otp-input-field v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Vue-Vite 3 OTP Input Field

Customizable OTP input field component for Vue 3 Vite.

Recommended to use with Vue Vite. Because Vue(without Vite) does not accept the emit funcitons as node package.

Preview

Gifphy

Demo

Demo link

Installation

To install:

npm i vue3-otp-input-field

OR

yarn add vue3-otp-input-field

OR

Without Build Tools

<script src="https://unpkg.com/vue3-otp-input-field"></script>

Usage

In your desired component add the OTP component with required props

<script setup>
import { ref } from "vue";
import { OTP } from "vue3-otp-input-field";

function logOtpValue(val = []) {
  code.value = val;
}
const code = ref([]);
const fieldSize = ref(6);

function handleSubmit() {
  console.log(code.value);
}
</script>

<template>
  <OTP
    size="medium"
    :fields="fieldSize"
    inputstyle="width: 80px; height: 50px; font-size: 40px; margin: 3px; border-radius: 5px;"
    type="mix"
    className="example-class-name"
    @OTPValueChanged="logOtpValue"
  />

  <div class="card">
    <button type="button" @click="handleSubmit">Submit</button>
  </div>
  <h1>{{ code }}</h1>
</template>

<style scoped></style>

Props parameters

Prop/AttributeTypeDescription
sizestringSize of the OTP component ("small", "medium", "large")
:fieldsnumberSpecify the number of input box
inputstylestringStyles applied to each input field (CSS inline styles)
typestringType of OTP ("number", "mix")
classNamestringAdditional class name(s) for styling or customization
@OTPValueChangedfunctionEvent handler for OTP value change (Vue.js event binding). Its a Emit function

Contribute

Contributions are always welcome!

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago