Install & Download:
# NPM
$ npm install @bachdgvn/vue-otp-input --saveDescription:
vue-otp-input is a customizable pin code component for one-time password input.
How to use it:
1. Install and import the component after vue.js.
import OtpInput from "@bachdgvn/vue-otp-input";
2. Register the component.
Vue.component("v-otp-input", OtpInput);3. Create the One-time Password Input component in your app template.
<template>
<div>
<v-otp-input
inputClasses="otp-input"
:numInputs="4"
separator="-"
:shouldAutoFocus="true"
@on-complete="handleOnComplete"
@on-change="handleOnChange"
/>
</div>
</template>4. Do something once the password input is changed and is completely filled.
export default {
methods: {
handleOnComplete(value) {
console.log("OTP: ", value);
},
handleOnChange(value) {
console.log("OTP: ", value);
}
}
};5. Apply your own CSS to the password input.
.otp-input {
width: 40px;
height: 40px;
padding: 5px;
margin: 0 10px;
font-size: 20px;
border-radius: 4px;
border: 1px solid rgba(0, 0, 0, 0.3);
textalign: "center";
}
.error {
border: 1px solid red !important;
}6. All possible props to customize the password input.
numInputs: {
default: 4,
},
separator: {
type: String,
default: '**',
},
inputClasses: {
type: String,
},
isInputNum: {
type: Boolean,
},
shouldAutoFocus: {
type: Boolean,
default: false,
}Preview:

Changelog:
v1.0.8 (06/16/2020)
- Update dependencies





