import { FormControl, FormLabel } from 'react-bootstrap'; import { LuKeyRound } from 'react-icons/lu'; const calculatePasswordStrength = password => { let strength = 0; if (password.length >= 8) strength++; if (/[A-Z]/.test(password)) strength++; if (/\d/.test(password)) strength++; if (/[\W_]/.test(password)) strength++; return strength; }; const PasswordInputWithStrength = ({ password, setPassword, id, label, name, placeholder, showIcon, labelClassName, inputClassName }) => { const strength = calculatePasswordStrength(password); const strengthBars = new Array(4).fill(0); return <> {label && {label} * }
setPassword(e.target.value)} /> {showIcon && }
{strengthBars.map((_, i) =>
)}

Use 8+ characters with letters, numbers & symbols.

; }; export default PasswordInputWithStrength;