1.0.1 ⢠Published 8 months ago
@xho/react-password-meter v1.0.1
React Password Strength Meter
A customizable, lightweight password strength meter component for React applications.
Features
šØ Multiple built-in themes (Classic, Emoji, Minimal)
šŖ Comprehensive strength calculation
š Fully customizable themes and scoring
š¦ Lightweight with zero dependencies
š» Written in TypeScript
ā”ļø Easy to integrate
š Common password detection
Installation
npm install @xho/react-password-meter
or
yarn add @xho/react-password-meter
Usage
Basic Usage
import { PasswordStrengthMeter } from "@xho/react-password-meter";
function App() {
return <PasswordStrengthMeter password="yourpassword" theme="classicTheme" />;
}
With Custom Theme
import { PasswordStrengthMeter, ThemeConfig } from "@xho/react-password-meter";
const customTheme: ThemeConfig = {
weak: { color: "#ff4d4d", label: "Too Weak" },
fair: { color: "#ffaa00", label: "Getting Better" },
good: { color: "#2196f3", label: "Almost There" },
strong: { color: "#4caf50", label: "Perfect!" },
};
function App() {
return (
<PasswordStrengthMeter
password="yourpassword"
theme={customTheme}
onChange={({ score, level }) => console.log(score, level)}
/>
);
}
Props
Prop | Type | Default | Description |
---|---|---|---|
password | string | "" | The password to evaluate |
theme | ThemeName \| ThemeConfig | "classicTheme" | Theme configuration |
showLabel | boolean | true | Whether to show strength label |
className | string | "" | Additional CSS classes |
onChange | (result: StrengthResult) => void | - | Callback when strength changes |
strengthCalculator | (password: string) => number | Built-in calculator | Custom strength calculation function |