New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

smooth-otp

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smooth-otp

A fast and small OTP input component for React/Nextjs - Debraj

latest
Source
npmnpm
Version
2.0.9
Version published
Maintainers
0
Created
Source

SmoothOTP Component

The SmoothOTP component is a flexible and user-friendly React component for inputting One-Time Passwords (OTPs). It supports two modes (slots and single-field), copy-pasting in the slots mode (including support for Android and iOS), and customizable styling.

Features

  • Two Modes:

    • slots: Separate input boxes for each OTP digit.
    • single-field: A single input box for the entire OTP.
  • Copy-Paste Support: Allows users to paste the OTP directly into the slots mode, with the pasted value distributed across the fields automatically.

  • Keyboard Navigation:

    • Auto-focus on the next field after entering a digit.
    • Backspace moves focus to the previous field if the current field is empty.
  • Customization:

    • Configurable length of OTP.
    • Custom class names for styling.
    • Adjustable spacing between inputs in slots mode.

Installation

npm install smooth-otp

Component API

alt text

Example Usage

import React from "react";
import { SmoothOTP } from "./SmoothOTP";

const App = () => {
  const handleComplete = (otp: string) => {
    console.log("Completed OTP:", otp);
  };

  return (
    <SmoothOTP
      length={6}
      type="slots"
      onComplete={handleComplete}
    />
  );
};

export default App;

Advance Customization

<SmoothOTP
  length={4}
  type="slots"
  onComplete={(otp) => console.log(otp)} 
  className="custom-otp-container"  // you can use tailwind classes here for outer layer
  inputClassName="custom-otp-input" // you can use tailwind classes here for inner layer
  spacing={10}
/>

Contributing

  • We welcome contributions! Follow these steps:
  • Fork the repository.
  • Create a branch for your feature or bug fix.
  • Submit a pull request describing your changes.

License

This project is licensed under the MIT License.

Upcoming Features

  • AUTO OTP Read for mobile devices (Android / IOS)
  • AUTO OTP Read for desktop browsers (https://developer.chrome.com/docs/identity/cross-device-webotp)
  • ARIA attribute addition

Keywords

react otp

FAQs

Package last updated on 23 Jan 2025

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