A customizable password strength meter component that provides real-time visual feedback on password security with requirement validation and auto-generation.
The Password Strength Meter component provides real-time visual feedback on password security, displays requirement checklists, and offers password visibility toggling and auto-generation features. It helps users create strong, secure passwords with clear visual indicators.
import { PasswordStrengthMeter } from "@/components/strength-meter"const calculateCustomStrength = (password: string): number => { let score = 0 // Length scoring if (password.length >= 8) score += 20 if (password.length >= 12) score += 20 if (password.length >= 16) score += 20 // Character variety if (/[a-z]/.test(password)) score += 10 if (/[A-Z]/.test(password)) score += 10 if (/\d/.test(password)) score += 10 if (/[^a-zA-Z0-9]/.test(password)) score += 10 return Math.min(score, 100)}export default function CustomStrengthPassword() { return ( <PasswordStrengthMeter customCalculateStrength={calculateCustomStrength} /> )}
Combine the Password Strength Meter with form validation libraries like Zod to enforce password requirements at the form level.
The default strength calculation considers password length, character variety (uppercase, lowercase, numbers, special characters), and common patterns. You can override this with customCalculateStrength.
Always validate password strength on the server-side as well. Client-side validation can be bypassed and should be considered a UX enhancement rather than a security measure.