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 🙏

© 2024 – Pkg Stats / Ryan Hefner

password-input-component

v1.0.8

Published

a password input component with a tooltip that displays password requirements and if they are met or not

Downloads

14

Readme

Password Input Component with tooltip

The Password Input Component is a reusable and secure UI component designed for user password input in web applications. It enhances security by including strength indication. The strength requirements default to the same as ASP.NET Core Identity and can be easily customized via props.

Password Input Component

Features

  • Masking: Masks the password as it is entered for privacy.
  • Strength Indicator: Provides real-time feedback on the entered password's strength.
  • Customizable: Easy to customize styles and behaviors.

Installation

To install the Password Input Component, you can use npm:

npm i password-input-component

Usage

After installation, you can import the Password Input Component into your project:

import PasswordInput from "password-input-component";

Example

import PasswordInput from "password-input-component";

function App() {
  return (
    <div>
      <PasswordInput />
    </div>
  );
}

export default App;

Props

The following props can be passed to the Password Input Component to customize its behavior:

  • inputName: The name property of the input element. Default: "password".

  • inputId: The id property of the input element. Default: "password".

  • inputPlaceholder: The placeholder property of the input element. Default: "".

  • isRequired: The required property of the input element. Default: true.

Example

<PasswordInput
  inputName="myPassword"
  inputId="myPassword"
  inputPlaceholder="Password"
  isRequired={false}
/>
  • minLength: Number that determines the minimum length of the password. Default: 6.

  • specialCharacter: Boolean that determines whether the password must contain at least one special character. Default: true.

  • lowercase: Boolean that determines whether the password must contain at least one lowercase character. Default: true.

  • uppercase: Boolean that determines whether the password must contain at least one uppercase character. Default: true.

  • digit: Boolean that determines whether the password must contain at least one number. Default: true.

Example

<PasswordInput
  minLength={12}
  specialCharacter={false}
  lowercase={false}
  uppercase={false}
  digit={false}
/>
  • onInputChange: Returns the event object when the input changes, just like the regular onChange function.

Example

<PasswordInput onInputChange={(e) => console.log(e.target.value)} />

or

import { useState } from "react";
import PasswordInput from "password-input-component";

function App() {
  const [password, setPassword] = useState("");

  const handleChange = (e) => {
    setPassword(e.target.value);
  };

  return (
    <>
      <PasswordInput onInputChange={(e) => handleChange(e)} />
    </>
  );
}

export default App;

Styling

The Password Input Component can be styled using CSS. Here are the classes you can target:

  • .password-input: The class for the input field.
  • .password-tooltip: The class for the tooltip. Must use !important to override the following default styles:

position / top / right / display / flex-direction / gap / padding / background-color / color

Example

.password-tooltip {
  background-color: red !important;
}
  • This code snippet will add an arrow pointing at the input element
.password-tooltip:after {
  content: "";
  position: absolute;
  left: -20px;
  top: 10px;
  transform: translateY(-50%);
  border: 10px solid rgba(0, 0, 0, 0.8);
  border-color: transparent rgba(0, 0, 0, 0.8) transparent transparent;
}

Arrow example

  • This code snippet will center the tooltip vertically with the input element
.password-tooltip:after {
  content: "";
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  border: 10px solid rgba(0, 0, 0, 0.8);
  border-color: transparent rgba(0, 0, 0, 0.8) transparent transparent;
}

.password-tooltip {
  top: -63px !important;
}

Centered tooltip example

Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project

  2. Create your Feature Branch

git checkout -b feature/AmazingFeature
  1. Commit your Changes
git commit -m 'Add some AmazingFeature'
  1. Push to the Branch
git push origin feature/AmazingFeature
  1. Open a Pull Request

Support

For support, please open an issue in the GitHub issue tracker for this project.

Thank you for using the Password Input Component!