npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@moonstone1258/vue3-verification-input

v1.0.5

Published

A feature-rich Vue 3 verification code input component with TypeScript support, auto-focus, paste handling, and success/error animations

Readme

@moonstone1258/vue3-verification-input

npm version License: MIT

A feature-rich and easy-to-use Vue 3 verification code input component with TypeScript support.

Features

  • ✅ Full TypeScript support
  • ✅ Responsive design (mobile & desktop)
  • ✅ Paste support for verification codes
  • ✅ Keyboard navigation (Arrow keys, Home, End)
  • ✅ Success/error state animations
  • ✅ Auto-focus and smart input management
  • ✅ Numeric input only
  • ✅ Accessibility (ARIA attributes)
  • ✅ Customizable length
  • ✅ Disabled state support
  • ✅ Zero dependencies (only Vue 3 peer dependency)

Installation

npm install @moonstone1258/vue3-verification-input

or

yarn add @moonstone1258/vue3-verification-input

or

pnpm add @moonstone1258/vue3-verification-input

Usage

Basic Usage

<script setup lang="ts">
import { ref } from 'vue'
import { VerificationCodeInput } from '@moonstone1258/vue3-verification-input'
import '@moonstone1258/vue3-verification-input/style.css'

const code = ref('')

const handleComplete = (value: string) => {
  console.log('Code completed:', value)
}
</script>

<template>
  <VerificationCodeInput
    v-model="code"
    :length="6"
    @complete="handleComplete"
  />
</template>

Global Registration

// main.ts
import { createApp } from 'vue'
import App from './App.vue'
import { Vue3VerificationInput } from '@moonstone1258/vue3-verification-input'
import '@moonstone1258/vue3-verification-input/style.css'

const app = createApp(App)
app.use(Vue3VerificationInput)
app.mount('#app')

Then use in any component:

<template>
  <VerificationCodeInput v-model="code" />
</template>

Advanced Usage with Ref

<script setup lang="ts">
import { ref } from 'vue'
import {
  VerificationCodeInput,
  type VerificationCodeInputInstance
} from '@moonstone1258/vue3-verification-input'
import '@moonstone1258/vue3-verification-input/style.css'

const code = ref('')
const inputRef = ref<VerificationCodeInputInstance>()

const handleComplete = async (value: string) => {
  // Simulate API validation
  const isValid = await validateCode(value)

  if (isValid) {
    inputRef.value?.showSuccess()
  } else {
    inputRef.value?.showError()
  }
}

const resetCode = () => {
  inputRef.value?.clear()
}
</script>

<template>
  <VerificationCodeInput
    ref="inputRef"
    v-model="code"
    :length="6"
    :auto-focus="true"
    @complete="handleComplete"
  />

  <button @click="resetCode">Reset</button>
</template>

API Reference

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | modelValue | string | '' | The v-model value (current code) | | length | number | 6 | Number of verification code digits | | disabled | boolean | false | Whether the input is disabled | | autoFocus | boolean | false | Auto-focus the first input on mount | | placeholder | string | '' | Placeholder text for empty inputs | | error | boolean | false | Show error state |

Events

| Event | Payload | Description | |-------|---------|-------------| | update:modelValue | (value: string) | Emitted when the value changes | | complete | (value: string) | Emitted when all inputs are filled | | change | (value: string) | Emitted when any input changes | | success | () | Emitted after success animation completes |

Methods (Exposed via ref)

| Method | Parameters | Description | |--------|------------|-------------| | focus() | - | Focus the first input | | clear() | - | Clear all inputs and focus the first one | | showError() | - | Show error state with shake animation, then clear | | showSuccess() | - | Show success state with animation, then clear |

TypeScript Support

import type {
  VerificationCodeInputProps,
  VerificationCodeInputEmits,
  VerificationCodeInputInstance
} from '@moonstone1258/vue3-verification-input'

Development

Install Dependencies

npm install

Development Mode

npm run dev

Build Library

npm run build

Type Check

npm run type-check

Detailed Features

Smart Focus Management

  • Automatically jumps to the next empty input box
  • Clicking a filled input box allows direct editing
  • Clicking an empty input box automatically focuses the first empty one
  • Automatically blurs when all inputs are filled

Keyboard Navigation

  • Number keys: Input numbers (0-9 only)
  • Backspace/Delete: Deletes the current input. Moves focus to the previous input if current is empty
  • Left/Right Arrow keys: Move between input boxes
  • Home: Jumps to the first input box
  • End: Jumps to the last input box
  • Ctrl/Cmd + V: Paste verification code

Paste Support

  • Automatically extracts numbers from pasted content
  • Starts filling from the current input box
  • Ignores non-numeric characters
  • Supports pasting full or partial verification code

State Animations

  • Error State: Red border + background + shake animation
  • Success State: Green border + background
  • Focus State: Blue border + shadow + slight scale-up
  • Inputs automatically cleared 500ms after state animation

Responsive Design

  • Mobile: 48px × 56px input boxes
  • Desktop: 56px × 64px input boxes
  • Adaptive spacing

Browser Support

  • Chrome/Edge (latest 2 versions)
  • Firefox (latest 2 versions)
  • Safari (latest 2 versions)
  • Mobile browsers (iOS Safari, Chrome Android)

License

MIT © moonstone1258

Repository

https://github.com/moonstone1258/vue3-verification-input