PasswordStrength

Evaluate password strength locally with a four-segment indicator and labels; the component does not persist, send, or submit passwords.

How to use

Pass the current password value from an input. The default heuristic considers length and character categories; minimumLength defaults to 8 and optional character requirements have independent guidance. It does not check breached or common passwords and does not guarantee security. Override evaluate and labels for your own policy and wording.

Import

import { PasswordStrength } from '@snowui-design-system/components';

Usage

Custom evaluation

Password requirements

API Reference

Property Type Default Example Description
password string "" password="Example" The caller-managed password to evaluate; it is not written to the DOM.
evaluate PasswordStrengthEvaluator evaluatePasswordStrength evaluate={(password) => password.length >= 12 ? 4 : 1} A synchronous function supplied by the caller that returns a strength level from zero to four.
labels readonly [string, string, string, string, string] ['Enter a password', 'Weak', 'Fair', 'Good', 'Perfect'] labels={['Enter a password', 'Weak', 'Fair', 'Good', 'Strong']} Five labels corresponding to strength levels zero through four.
minimumLength number 8 minimumLength={42} Minimum number of characters, also used by the default evaluation.
minimumLengthMessage (length: number) => string Current locale length message minimumLengthMessage={(value) => { /* handle value */ }} Custom message shown first when a non-empty password is too short.
requireLowercase boolean false requireLowercase Require at least one ASCII lowercase letter.
requireUppercase boolean false requireUppercase Require at least one ASCII uppercase letter.
requireNumber boolean false requireNumber Require at least one digit from 0 through 9.
requireSymbol boolean false requireSymbol Require at least one non-letter, non-digit, non-whitespace character; examples include ! @ # $ %.
No data