# v-otp

> **An Accessible OTP Input Component for Vue 3**

Latest version **0.0.14** (published 2023-12-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install v-otp
pnpm add v-otp
yarn add v-otp
bun add v-otp
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.14 |
| Published | 2023-12-28 |
| First published | 2023-12-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Saman Safaei |
| Maintainers | mythril-ui |
| Keywords | vue, otp, pin-input, vue3, input, component, one-time-password, accessible, unstyled |

## Links

- npm: https://www.npmjs.com/package/v-otp
- Repository: https://github.com/Saman-Safaei-Dev/v-otp
- Homepage: https://github.com/Saman-Safaei-Dev/v-otp#readme
- Issues: https://github.com/Saman-Safaei-Dev/v-otp/issues
- npm.io page: https://npm.io/package/v-otp

## Recent versions

- 0.0.14 (latest) — 2023-12-28
- 0.0.13 — 2023-12-28
- 0.0.12 — 2023-12-28
- 0.0.11 — 2023-12-28
- 0.0.10 — 2023-12-28
- 0.0.9 — 2023-12-28
- 0.0.8 — 2023-12-28
- 0.0.6 — 2023-12-26
- 0.0.5 — 2023-12-24
- 0.0.4 — 2023-12-24
- 0.0.3 — 2023-12-24
- 0.0.2 — 2023-12-24
- 0.0.1 — 2023-12-24

## README

# V-OTP
**An Accessible OTP Input Component for Vue 3**

V-OTP is a Vue 3 component library designed to provide an accessible OTP (One-Time Password) input solution. With V-OTP, you can easily integrate OTP functionality into your Vue 3 projects.

### Installation

To install V-OTP, simply run the following command:

```bash
npm i v-otp
yarn add v-otp
pnpm i v-otp
```

### Basic Usage

Once installed, you can use V-OTP in your Vue 3 components. Here's an example of basic usage:

```vue
<script setup>
import { ref } from 'vue'
import VOtp from 'v-otp'

const otp = ref('')
</script>

<template>
  <VOtp v-model="otp" :fields="4" class="size-8 text-center" />
</template>
```

In the above example, the `VOtp` component is imported from the `v-otp` package. It is bound to a `ref` named `otp` using `v-model`, which allows for two-way data binding. The `fields` prop is set to `4`, indicating that the OTP input should have four fields. The component is also given additional styling classes for customization.

### Props

V-OTP accepts the following prop:

| Prop          | Type          | Required      | Default       |
| ------------- | ------------- | ------------- | ------------- |
| `fields`      | `number`      | `false`       | `5`           |

- **`fields`**: The `fields` prop specifies the number of OTP fields to display. By default, it is set to `5`, but you can customize it as per your requirements.

### Emits

V-OTP emits the following events:

| Emit          | Type                         |
| ------------- | ---------------------------- |
| `@change`     | `(value: string) => void`    |
| `@complete`   | `(value: string) => void`    |

- **`@change`**: The `@change` event is triggered whenever the OTP value changes. It provides the updated value as a string. 
- **`@complete`**: The `@complete` event is emitted when the OTP input is complete, meaning all fields have been filled. It also provides the complete OTP value as a string.

With V-OTP, you can easily incorporate an accessible OTP input component into your Vue 3 projects, enabling users to input one-time passwords effortlessly.

---
_Source: https://npm.io/package/v-otp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
