1.1.0 • Published 4 years ago

react-password-strength-variant-indicator v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

React Password Strength Indicator

A password strength checker with various indicator options using zxcvbn library.

Demo App

Try it live

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development.

Prerequisites

react/react-dom is a peer dependency. You should be using this in a React project.

Installing

Add password strength indicator to your project by executing

npm install react-password-strength-variant-indicator

Usage

Here's an example of basic usage:

import React, { Component } from 'react';
import StrengthCheck from "react-password-strength-variant-indicator";

class MyApp extends Component {
  state = {
    inputprops: { inputclass: "form-control", autocomplete: "off", tabIndex: 0 },
    value: ''
  }

  changeCallBackHandler = value => {
   this.setState({ value: value })
  };
  
  render() {
    return (
      <div>
        <StrengthCheck
        changecallback={val => {
          changeCallBackHandler(val);
        }}
        validscore="1"
        inputprops={this.state.inputprops}
        variant="circle"
      />
      </div>
    );
  }
}

User guide

Props

Prop nameDescriptionDefault valueExample values
minLengthThe minimum length of password to be typed.5minLength=6
validscoreThe minimum valid score the password should have(The score value ranges from 0 to 4 depends on strength and complexity)2validscore=3
strengthThe strength of the password based on the score{ 0: "Worst", 1: "Bad",2: "Weak",3: "Good",4: "Strong"}strength={0: "Weak",1: "Weak",2: "moderate",3: "Good",4: "Strong"}
classNameThe className which get added to the componentNoclassName=form
inputpropsObject which accepts all the parameters that will be used in input tagNoinputprops={{inputclass: 'form-control-input',autocomplete: 'off'tabIndex=-1,}
variantThis gives different types of variant options that can be choosed for strength displaylinear-strippedvariant=line
changecallbackA callback function which gets triggered onChange which gives the input value in the format {value: typedValue,isValid: boolean,score: score}.isValid is a boolean which depends on the input length and score.score value ranges from 0 to 4 which depends on password strength and complexity.value gives the inputvalue in the fieldNochangecallback={val => {changeCallBackHandler(val);}}

variants

variant nameExample
variant=linear
variant=linear-stripped
variant=discontinuous
variant=discontinuous-stripped
variant=circle
variant=line

License

This project is licensed under the MIT License - see the LICENSE.md file for details

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago