Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@healerlab/vue3-simple-otp-input

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@healerlab/vue3-simple-otp-input

Powerful, lightweight, and reusable OTP input component for Vue 3

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
332
increased by50.91%
Maintainers
1
Weekly downloads
 
Created
Source

Vue 3 simple OTP input

npm npm GitHub

Demo

Demo and docs

Installation

Prerequisites

To get started, you can install vue3-simple-otp-input with:

npm i @healerlab/vue3-simple-otp-input

with pnpm:

pnpm add @healerlab/vue3-simple-otp-input

with yarn:

yarn add @healerlab/vue3-simple-otp-input

Usage

Import the component and register it locally in your Vue component:

<script setup lang="ts">
import { HOtpInput } from "@healerlab/vue3-simple-otp-input";

const handleFinish = (otpCode: string) => {
  // write logic with received code
}

const handleChange = (otpCode: string) => {
  // write logic with changed code
}

const getCodeWithSeparator = () => {
  // get code with separator
  // otpInput?.value?.genResultWithSeparator()
}
</script>

Use the component in your template:

<HOtpInput
  :length="6" 
  type="text" 
  @on-finish="handleFinish"
  @on-change="handleChange" 
  wrapperClassName="otp-input"
  :outlined="true"
  ref="otpInput"
  :only-number="true"
  separator="-" // separator support
  separatorType="middle" // middle or all
/>

This is minimal style for your input, you can change it to match your use-case:

<style scoped lang="scss">
.otp-input {
  :deep(input) {
    outline: none;
    width: 30px;
    padding: 12px;
    font-size: 22px;
    border: none;
    margin-left: 10px;
    text-align: center;
    &:first-child {
      margin-left: 0;
    }
    &:focus {
      outline: none
    }
  }

  :deep(span) {
    padding: 0 0px 0 10px;
    font-size: 30px;
  }
}
</style>

See the Vue3 Simple OTP Input page for more information.

Keywords

FAQs

Package last updated on 06 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc