Socket
Book a DemoInstallSign in
Socket

@mvp-rockets/react-otp-input

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mvp-rockets/react-otp-input

A fully customizable, one-time password input component for the web built with React

latest
Source
npmnpm
Version
1.0.0-beta.3
Version published
Maintainers
2
Created
Source

@mvp-rockets/react-otp-input

GitHub package.json version npm npm All Contributors

A fully customizable, one-time password input component for the web built with React. This package is based on great work of contributers of react-otp-input. But i needed this package and for unknown reasons the contributers of the original package does not accept the open PRs that solve the REACT 18 dependency problem. So based on The PR here i created this package for the others who need this. To see the original package Click

CodeSandbox & LiveDemo

Installation

NPM

To install the latest stable version:

npm install --save @mvp-rockets/react-otp-input

Basic usage:

import React, { useState } from 'react';

import OtpInput from '@mvp-rockets/react-otp-input';

function App() {
  const [otp, setOtp] = useState('');

  return (
    <OtpInput
      inputStyle="inputStyle"
      numInputs={4}
      onChange={(value) => setOtp(value)}
      separator={<span>-</span>}
      isInputNum={true}
      shouldAutoFocus
      value={otp}
    />
  );
}

export default App;

API

Name
TypeRequiredDefaultDescription
numInputsnumbertrue4Number of OTP inputs to be rendered.
onChangefunctiontrueconsole.logReturns OTP code typed in inputs.
valuestring / numbertrue''The value of the OTP passed into the component.
placeholderstringfalsenoneSpecify an expected value of each input. The length of this string should be equal to numInputs.
separatorcomponent
falsenoneProvide a custom separator between inputs by passing a component. For instance, <span>-</span> would add - between each input.
containerStylestyle (object) / className (string)falsenoneStyle applied or class passed to container of inputs.
inputStylestyle (object) / className (string)falsenoneStyle applied or class passed to each input.
focusStylestyle (object) / className (string)falsenoneStyle applied or class passed to inputs on focus.
isDisabledbooleanfalsefalseDisables all the inputs.
disabledStylestyle (object) / className (string)falsenoneStyle applied or class passed to each input when disabled.
hasErroredbooleanfalsefalseIndicates there is an error in the inputs.
errorStylestyle (object) / className (string)falsenoneStyle applied or class passed to each input when errored.
shouldAutoFocusbooleanfalsefalseAuto focuses input on initial page load.
isInputNumbooleanfalsefalseRestrict input to only numbers.
isInputSecurebooleanfalsefalseMasks input characters.
data-cystringfalse-Test attribute passed to the inputs.
data-testidstringfalse-Test attribute passed to the inputs.

Development

To run the development server:

npm run dev

License

NPM

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Mahdi Mohaqeq
Mahdi Mohaqeq

💻🚧 🤔 👀

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

otp

FAQs

Package last updated on 10 Jan 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.