ui-kit0.0

Signature

Password strength

A live meter and requirement checklist.

Sign-up password

A four-segment meter and a checklist under the input. Segments fill in order as the password gets stronger, and each requirement ticks off with a small pop as it is met.

  • Not met: At least 8 characters
  • Not met: Upper and lower case letters
  • Not met: A number
  • Not met: A symbol

When to use

  • Creating or changing a password, where feedback while typing prevents a rejected submit.
  • Passphrases with house rules (minimum length, words to avoid) — pass your own requirements.

Not for: sign-in forms (never rate a password someone already has), or as the only check — the score is guidance for people, the server still validates.

Meter only

showChecklist={false} keeps just the meter and its word. scorePassword is exported, so the form can use the same score to enable its submit button.

Use 12 or more characters. A short sentence works well.

Custom requirements

Each requirement is { id, label, test }. A password can only rate strong when every requirement is met. Define the list outside the component so it keeps its identity between renders.

  • Not met: At least 12 characters
  • Not met: Two or more words
  • Not met: Doesn’t contain “northwind”

Scoring

  • Length: 8–11 characters 1 point, 12–15 two, 16 or more three.
  • Variety: one point for each kind of character beyond the first (lower case, upper case, numbers, symbols).
  • A straight run such as “1234” or “abcd” costs a point.
  • Points map to 1 weak (0–1), 2 fair (2–3), 3 good (4) and 4 strong (5+).
  • Common passwords and a single repeated character are always weak.

API

PasswordStrength

PropTypeDefaultDescription
valuestring—The password being typed.
requirementsPasswordRequirement[]defaultPasswordRequirements{ id, label, test(password) }. Default: 8+ characters, upper and lower case, a number, a symbol.
labels{ weak?, fair?, good?, strong? }Weak / Fair / Good / StrongThe word beside the meter.
showChecklistbooleantrueShow the requirement checklist.
showLabelbooleantrueShow the level word (also the live region).
meterLabelstring'Password strength'Accessible name of the meter.
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the root, including id (for aria-describedby), ref and className.

scorePassword(password, requirements?) → PasswordStrengthResult

PropTypeDefaultDescription
score0 | 1 | 2 | 3 | 4—Empty, weak, fair, good, strong.
level'empty' | 'weak' | 'fair' | 'good' | 'strong'—Also on the root as data-level.
requirements{ id, label, met }[]—The checklist state.
metCountnumber—How many requirements are met.

Keyboard

KeyAction
TabThe meter and checklist are not focusable; focus stays in the password input.

Accessibility

  • Give the root an id and point the input’s aria-describedby at it, so the strength and checklist are read with the field.
  • The meter is role="meter" (0–4) with the level word as its value text.
  • The level word is a polite, atomic live region: it speaks only when the level changes, not on every keystroke.
  • Each requirement carries hidden “Met:” or “Not met:” text; the check marks are decorative.
  • Colour is never the only signal: the word and the number of filled segments say the same thing.

Motion

  • Segments grow from the start edge on the smooth spring, 35ms apart, counted from the previous score so only the segments that change wait.
  • A met requirement’s mark fills with the success colour and its check scales in on the snappy spring.
  • Colour shifts between levels over 220ms.
  • Reduced motion: segments and marks change state instantly, with no stagger.