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

mehdi-akbari-otp-input

v0.1.2

Published

A professional and customizable Persian (Jalali) calendar component for React.

Readme

React OTP Input

یک کامپوننت OTP حرفه‌ای، سبک، قابل سفارشی‌سازی و سازگار با SSR برای React.
این کامپوننت از دو حالت single و multiple پشتیبانی می‌کند و امکاناتی مثل امنیت، دسترسی‌پذیری، RTL، کنترل کامل رفتار ورودی و UX هوشمند را ارائه می‌دهد.


✨ ویژگی‌ها

  • پشتیبانی از دو حالت ورودی:
    • single → یک ورودی با اسلات‌های مجازی
    • multiple → چند ورودی مستقل
  • پشتیبانی از انواع ورودی:
    • numeric، alphanumeric، text
  • پشتیبانی از الگوی سفارشی (pattern)
  • حالت امنیتی (secure) برای نمایش نقطه به‌جای کاراکتر
  • مدیریت کامل Paste، Backspace و Navigation
  • پشتیبانی از RTL و LTR
  • پشتیبانی از Placeholder، Separator و AutoFocus
  • رویدادهای onChange و onComplete
  • دسترسی‌پذیری کامل (A11y)
  • سازگار با SSR و Next.js
  • سبک، بدون وابستگی‌های غیرضروری

📦 نصب

npm install your-otp-input
# یا
yarn add your-otp-input
🚀 استفاده سریع
حالت Multiple (پیش‌فرض)
tsx
import { OtpInput } from "your-otp-input";

export default function Example() {
  return (
    <OtpInput
      length={6}
      onComplete={(code) => console.log("OTP:", code)}
    />
  );
}
حالت Single
tsx
<OtpInput
  mode="single"
  length={6}
  placeholder="-"
  secure
/>
⚙️ Props
نام	نوع	پیش‌فرض	توضیح
length	number	4	تعداد کاراکترهای OTP
onChange	(value: string) => void	—	هنگام تغییر مقدار
onComplete	(value: string) => void	—	وقتی مقدار کامل شد
className	string	—	کلاس سفارشی
style	CSSProperties	—	استایل inline
dir	`'ltr' \	'rtl'`	'ltr'	جهت ورودی
disabled	boolean	false	غیرفعال کردن ورودی
autoFocus	boolean	false	فوکوس خودکار
separator	ReactNode	—	جداکننده بین سلول‌ها
placeholder	string	—	placeholder هر سلول
mode	`'single' \	'multiple'`	'multiple'	حالت ورودی
inputType	`'numeric' \	'alphanumeric' \	'text'`	'numeric'	نوع ورودی
pattern	RegExp	—	الگوی سفارشی
secure	boolean	false	نمایش نقطه به‌جای کاراکتر
isError	boolean	false	حالت خطا (انیمیشن shake)
ariaLabel	string	"Verification Code"	لیبل دسترسی‌پذیری
renderInputAriaLabel	(index, total) => string	—	لیبل سفارشی برای هر سلول
🎨 استایل‌دهی
این کامپوننت کلاس‌های پایه زیر را ارائه می‌دهد:

کلاس	توضیح
otp-container	کانتینر اصلی
otp-input-base	استایل پایه ورودی
otp-field	ورودی‌های حالت multiple
otp-slot	اسلات‌های حالت single
otp-hidden-input	ورودی مخفی حالت single
otp-error	حالت خطا
otp-shake	انیمیشن خطا
otp-caret	نشانگر فعال
می‌توانید به‌راحتی override کنید:

css
.otp-field {
  border: 1px solid #ccc;
  border-radius: 8px;
}
♿ دسترسی‌پذیری (A11y)
استفاده از aria-label برای ورودی‌ها

استفاده از aria-live برای اعلام تکمیل OTP

پشتیبانی از aria-invalid در حالت خطا

پشتیبانی از screen reader برای هر سلول

🧪 رویدادها
onChange(value: string)
هنگام تغییر مقدار OTP

onComplete(value: string)
وقتی مقدار کامل شد (مثلاً ۶ رقم)

📄 لایسنس
MIT

🇬🇧 English README
(Professional, clean, npm‑ready)

md
# React OTP Input

A lightweight, accessible, customizable OTP (One-Time Password) input component for React.  
Supports both **single-input** and **multi-input** modes with full control over validation, UX behavior, accessibility, and styling.

---

## ✨ Features

- Two input modes:
  - `single` → one hidden input with visual slots
  - `multiple` → separate input fields
- Input types: `numeric`, `alphanumeric`, `text`
- Custom validation via RegExp (`pattern`)
- Secure mode (mask characters with •)
- Smart handling of paste, backspace, and navigation
- RTL & LTR support
- Custom placeholders and separators
- `onChange` and `onComplete` callbacks
- Full accessibility (A11y) support
- SSR-friendly (Next.js compatible)
- Zero unnecessary dependencies

---

## 📦 Installation

```bash
npm install your-otp-input
# or
yarn add your-otp-input
🚀 Quick Usage
Multiple Mode (default)
tsx
import { OtpInput } from "your-otp-input";

export default function Example() {
  return (
    <OtpInput
      length={6}
      onComplete={(code) => console.log("OTP:", code)}
    />
  );
}
Single Mode
tsx
<OtpInput
  mode="single"
  length={6}
  placeholder="-"
  secure
/>
⚙️ Props
Prop	Type	Default	Description
length	number	4	Number of OTP digits
onChange	(value: string) => void	—	Triggered on value change
onComplete	(value: string) => void	—	Triggered when OTP is fully filled
className	string	—	Custom class
style	CSSProperties	—	Inline styles
dir	`'ltr' \	'rtl'`	'ltr'	Input direction
disabled	boolean	false	Disable input
autoFocus	boolean	false	Auto-focus first field
separator	ReactNode	—	Separator between fields
placeholder	string	—	Placeholder for each cell
mode	`'single' \	'multiple'`	'multiple'	Input mode
inputType	`'numeric' \	'alphanumeric' \	'text'`	'numeric'	Input type
pattern	RegExp	—	Custom validation pattern
secure	boolean	false	Mask characters
isError	boolean	false	Error state (shake animation)
ariaLabel	string	"Verification Code"	A11y label
renderInputAriaLabel	(index, total) => string	—	Custom per-cell aria-label
🎨 Styling
Base CSS classes:

Class	Description
otp-container	Main wrapper
otp-input-base	Base input style
otp-field	Input fields (multiple mode)
otp-slot	Visual slots (single mode)
otp-hidden-input	Hidden input (single mode)
otp-error	Error state
otp-shake	Shake animation
otp-caret	Active caret indicator
Example override:

css
.otp-field {
  border: 1px solid #ddd;
  border-radius: 6px;
}
♿ Accessibility (A11y)
aria-label for each input

aria-live announcements for completion

aria-invalid for error states

Screen reader–friendly structure

🧪 Events
onChange(value: string)
Fired whenever the OTP value changes.

onComplete(value: string)
Fired when the OTP reaches full length.

📄 License
MIT