Skip to content

Password Strength

A segmented meter with a written label, a live checklist of your rules, and a strong password one click away.

On this page
Used for
  • Sign-up form
  • Change password
  • Set a workspace secret
  • Team invite setup

Examples

Sign-up form

Change password

Custom rules

Installation

npx knowns-ui@latest add password-strength
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

value
string
The password being typed.
userInputs
string[]
Default[]
Name, email and the like. A password containing them fails that rule and scores Weak at most.
rules
PasswordRule[]
DefaultpasswordRules()
The checklist. passwordRules({ minLength, mixedCase, number, symbol, notCommon, notPersonal }) builds the usual ones; add { id, label, test } for your own.
checklist
boolean
Defaulttrue
Show the checklist under the meter.
segments
4 | 5
Default4
Meter segments.
onGenerate
(password) => void
Shows "Generate strong password", then Copy. Fill your field with the value and reveal it.
generate
{ length?, symbols? }
Default{ length: 20, symbols: true }
Generated passwords use every class and skip look-alikes (0/O, 1/l/I).
announceDelay
number
Default700
Milliseconds after typing stops before the strength is announced.
score
(value, { userInputs }) => StrengthResult
DefaultscorePassword
Swap in your own estimate, for example from your server.

The label is always written out (Too weak, Weak, Okay, Strong, Very strong), so colour is never the only signal. The meter is a role="meter" with the label as its value text, and checklist items read as "Done" or "Not yet". Changes are announced politely once typing pauses. Segments fill and ticks draw with a short transition; with reduced motion they change at once.

scorePassword, passwordRules, checkPassword and generatePassword are plain functions you can use on their own. The score is an estimate from length and character variety, minus repeats, runs such as abc or qwer, a short built-in list of very common passwords and the user's own details. It guides people; check your real policy on the server.

What it handles

  1. 01Scores a value from 0 to 4 with scorePassword: an entropy estimate from length and character classes, with penalties for repeats, runs and common words.
  2. 02Lowers the score when the password contains words from userInputs such as a name or email, and caps it when it is on the common list.
  3. 03Draws 4 or 5 segments with a text label, and exposes the meter as role meter with a plain-language valuetext.
  4. 04Lists live rules from passwordRules (length, mixed case, a number, a symbol, not common, not personal), and you can add your own { id, label, test }.
  5. 05Generates a strong password with crypto randomness through onGenerate, then offers a Copy button for the generated value.
  6. 06Waits announceDelay after typing stops before the polite screen reader message, and accepts your own score function for a server estimate.

States

First render
Nothing. The meter paints empty with the label Strength
none
Score changes
Segments fill or empty left to right with a stagger
280ms, ease in-out, up to 4 steps of 40ms
Label change
The old label fades up and the new one fades in with a short slide
180ms, ease out
Rule met
The empty ring turns into a filled check that draws its tick
180ms, ease out
Very strong reached
One sweep of light crosses the bar
280ms, ease out
Hint line
The advice under the bar fades in or out, nothing moves
180ms, opacity only
Reduced motion
Segments, checks and labels change at once and the sweep is skipped
0ms

Works with

When to use

When to use

  • Sign-up and change-password forms, so people see what a good password needs as they type.

When not to use

  • Sign-in forms: never judge an existing password there: use Password Field.
  • Your real policy: enforce it on the server too.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Password Strength to my app and wire it to my own data.
  • I need sign-up and change-password forms, so people see what a good password needs as they type. Set that up with the Knowns UI Password Strength.
  • Which Password Strength props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "password-strength" }) and search_docs({ query: "password strength" }).

Need help?

Stuck on Password Strength, or found something off? We read every message.