# vue3-otp-input
> Vue 3 OTP Input is a 5.0 KB fully customizable OTP (one-time password) input component for OTPs, transaction pins, and passwords built with Vue 3.x and Vue Composition API..
## Documentation
Link to doc
## ðđ Demo

## âïļ Installation
### Install as package
You can install `vue3-otp-input` via the terminal.
```sh
pnpm i vue3-otp-input
```
OR
### Install via CDN
```sh
```
## ð Usage [Demo](https://github.com/ejirocodes/vue3-otp-input/blob/main/src/App.vue)
### 1/3. Register as a Vue component locally OR
```ts
```
### 1/3. Register as a Vue component globally
```js
// main.js or main.ts
import { createApp } from 'vue'
import App from './App.vue'
import VOtpInput from "vue3-otp-input";
const app = createApp(App)
app.component('v-otp-input', VOtpInput).mount('#app')
```
### 2/3. Use the registered component in your Vue template
```html
```
### 3/3 [Optional]. Some basic styling options
#### This css has to go into a `
```
## ð Props
Name
Type
Required
Default
Description
value
string
false
""
v-modal:value for bind dynamic value
num-inputs
number
true
4
Number of OTP inputs to be rendered.
separator
component
false
Provide a custom separator between inputs by passing a component. For instance, <span>-</span> would add - between each input
This allows a browser to display an appropriate virtual keyboard. Optional value: "numeric", "text", "tel". [Learn More](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode)
should-auto-focus
boolean
false
false
Auto focuses input on inital page load.
should-focus-order
boolean
false
false
Auto correct the input order. See https://github.com/ejirocodes/vue3-otp-input/pull/39
placeholder
array
false
[]
Specify an expected value for each input. Example: :placeholder="['*', '*', '*', '*']". The length of this array should be equal to num-inputs.
conditionalClass
array
false
[]
Specify a class to be applied to each input based on the value of the input. Example: :conditionalClass="['one', 'two', 'three', 'four']". The length of this array should be equal to num-inputs.
is-disabled
boolean
false
false
Disables all the input fields.
## ðĪš Methods
Name
Description
clearInput()
Use with ref for clearing all otp inputs, see code example section.
fillInput()
Use with ref for fill otp inputs. The value should be same length as `numInputs` length. See code example section.
## ðī Events
Name
Description
on-change
Return OTP code was changing when we made a change in inputs.
on-complete
Return OTP code typed in inputs.
## ðĪð― License
[MIT](https://choosealicense.com/licenses/mit/)
## ð Contributing
Contributions are always welcome!
See `contributing.md` for ways to get started.
Please adhere to this project's `code of conduct`.
## ð§ļ Appendix
This component is a rewite of [vue-otp-input](https://github.com/bachdgvn/vue-otp-input) component to support Vue 3.x. Feel free to use it in your project, report bugs and make PR ðð―.