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

react-auth-code-input

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-auth-code-input

One-time password (OTP) React input component, uncontrolled, zero dependencies, fully tested.

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
58K
increased by114.53%
Maintainers
1
Weekly downloads
 
Created
Source

image

React Auth Code Input

One-time password (OTP) React input component, uncontrolled, zero dependencies, fully tested.

NPM JavaScript Style Guide Software License npm npm GitHub actions state

Demo

Demo

Install

npm install --save react-auth-code-input

or

yarn add react-auth-code-input

Usage

import React, { useState } from 'react';
import AuthCode from 'react-auth-code-input';

const App = () => {
  const [result, setResult] = useState('');
  const handleOnChange = (res: string) => {
    setResult(res);
  };

  return (
    <AuthCode
      length={5}
      onChange={handleOnChange}
      containerClassName='container'
      inputClassName='input'
    />
  );
};

Props

PropTypeDescriptionDefault ValueObservations
allowedCharactersStringType of allowed characters for your code.alphanumericalpha, alphanumeric, numeric
ariaLabelStringAccessibility.
lengthNumberThe number of inputs to display.6
containerClassNameStringThe styles to be applied to the container.
inputClassNameStringThe styles to be applied to each input.
onChangeFunction(value: String)Callback function called every time an input value changes.
isPasswordBooleanWhether to display the inputs as passwords or not.false

Changelog

3.0.0

  • Change the way the allowed characters are handled by using 3 predefined modes: alpha, alphanumeric, and numeric, allowing to have more control when validating the values introduced in the inputs.
  • Improved logic.
  • Improved tests.
  • Improved types.

2.1.0

  • Support to fill one-time-codes directly from SMS's.
  • Displays numeric keyboard on mobile devices when the inputType prop is set to number
  • Add ariaLabel prop for accessibility.

2.0.0

  • Remove inputStyle prop in favor of inputClassName.
  • Remove containerStyle prop in favor of containerClassName.
  • Remove password prop in favor of inputType which accepts text, password or number value.

1.2.1

  • Add missing dist files.

1.2.0

  • Add inputClassName and containerClassName props.
  • Deprecate inputStyle and containerStyle.
  • Make onChange prop mandatory.

1.1.0

  • Typescript support.

1.0.0

  • Initial Version.

Props versions 1 and 2

PropTypeDescriptionDefault ValueObservations
allowedCharactersStringRegex for allowed characters[A-Za-z0-9]+
ariaLabelStringAccessibility
charactersNumberThe number of inputs to display6
containerClassNameStringThe styles to be applied to the container
inputClassNameStringThe styles to be applied to each input
inputTypeStringThe type of the inputstexttext, number or password
onChangeFunction(value: String)Callback function called every time an input value changes
passwordBooleanIf present changes the type of the input to password, by default is set to textfalsedeprecated since version 2.0.0
inputStyleObjectThe styles to be applied to each inputdeprecated since version 1.2.0
containerStyleObjectThe styles to be applied to the containerdeprecated since version 1.2.0

License

Licensed under the MIT License, Copyright © 2020-present Luis Guerrero drac94.

See LICENSE for more information.

Keywords

FAQs

Package last updated on 14 Feb 2022

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