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

passwise

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passwise

A customizable React password strength checker library

latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
1
Created
Source

Passwise

A highly customizable React component library for password strength checking and validation.

npm version License: MIT TypeScript

Features

  • 🔒 Robust Security Analysis: Uses the battle-tested zxcvbn library originally created by Dropbox for password strength estimation
  • 🎨 Fully Customizable UI: Light and dark theme support with further customization options
  • 🧩 Headless Option: Use the usePasswordStrength hook for complete UI control
  • 📏 Custom Password Policies: Define your own password requirements
  • 🔄 Real-time Feedback: Strength meter, validation state, and improvement suggestions
  • 📦 Modern Bundle: Tree-shakable ESM and CommonJS builds
  • 📝 Type-safe: Written in TypeScript with comprehensive type definitions
  • 🎯 Optional TailwindCSS: Styling with Tailwind, but also works without it

Installation

# npm
npm install passwise

# yarn
yarn add passwise

# pnpm
pnpm add passwise

Usage

Basic Example

import React, { useState } from "react";
import { PasswordStrengthMeter } from "passwise";

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

  return (
    <div>
      <input
        type="password"
        value={password}
        onChange={(e) => setPassword(e.target.value)}
      />

      <PasswordStrengthMeter
        password={password}
        theme="dark"
        policy={{
          minLength: 8,
          mustContain: {
            lowercase: true,
            uppercase: true,
            number: true,
            symbol: true,
          },
        }}
      />
    </div>
  );
}

With Custom Password Policy

import React, { useState } from 'react';
import { PasswordStrengthMeter } from 'passwise';

function PasswordFormWithPolicy() {
  const [password, setPassword] = useState('');

  // Define a custom password policy
  const passwordPolicy = {
    minLength: 8,
    mustContain: {
      lowercase: true,
      uppercase: true,
      number: true,
      symbol: true
    }
  };

  return (

      <input
        id="password"
        type="password"
        value={password}
        onChange={(e) => setPassword(e.target.value)}
      />

    <PasswordStrengthMeter
        password={password}
        theme="dark"
        policy={passwordPolicy}
      />


  );
}

Using the Hook (Headless)

import React, { useState } from 'react';
import { usePasswordStrength } from 'passwise';

function CustomPasswordUI() {
  const [password, setPassword] = useState('');

  // Use the headless hook
  const strengthResult = usePasswordStrength({
    password,
    policy: {
      minLength: 10
    }
  });

  // Create your own UI based on the strength result
  return (

      <input
        type="password"
        value={password}
        onChange={(e) => setPassword(e.target.value)}
      />


        Strength score: {strengthResult.score}/4
        Rating: {strengthResult.label}

        {strengthResult.feedback.warning && (
          Warning: {strengthResult.feedback.warning}
        )}

        {strengthResult.feedback.suggestions.length > 0 && (

            {strengthResult.feedback.suggestions.map((suggestion, i) => (
              {suggestion}
            ))}

        )}


  );
}

API Reference

PasswordStrengthMeter Props

PropTypeDefaultDescription
passwordstringrequiredThe password to evaluate
theme'light' | 'dark''light'UI theme
classNamestring''Additional CSS classes
showLabelsbooleantrueShow strength labels
showBarbooleantrueShow strength bar
showSuggestionsbooleantrueShow validation and suggestions
scoreWords[string, string, string, string, string]['Very Weak', 'Weak', 'Fair', 'Good', 'Strong']Custom labels for each strength level
policyPasswordPolicyundefinedCustom password requirements
barOnlybooleanfalseShow only the strength bar
onChange(result: PasswordStrengthResult) => voidundefinedCallback when strength changes

PasswordPolicy Object

interface PasswordPolicy {
  minLength?: number;
  maxLength?: number;
  mustContain?: {
    lowercase?: boolean;
    uppercase?: boolean;
    number?: boolean;
    symbol?: boolean;
  };
}

PasswordStrengthResult Object

interface PasswordStrengthResult {
  score: 0 | 1 | 2 | 3 | 4; // 0 = weakest, 4 = strongest
  label: "Very Weak" | "Weak" | "Fair" | "Good" | "Strong";
  feedback: {
    suggestions: string[];
    warning: string | null;
  };
  passwordLength: number;
  validations: PasswordValidationResult[];
  meetsPolicy: boolean;
}

Styling and Customization

Using TailwindCSS

This library provides default styling using TailwindCSS. The classes are prefixed with pw- to avoid conflicts with your application's own Tailwind classes.

Without TailwindCSS

If you're not using TailwindCSS, the components will still work, but you might want to provide your own styling via the className prop and CSS.

License

MIT

Keywords

react

FAQs

Package last updated on 20 May 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