A segmented meter with a written label, a live checklist of your rules, and a strong password one click away.
- 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-strengthPaste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install Password strength from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/password-strength
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add password-strength
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/password-strength.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/password-strength, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "password-strength" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.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[]- Default
passwordRules() - The checklist. passwordRules({ minLength, mixedCase, number, symbol, notCommon, notPersonal }) builds the usual ones; add { id, label, test } for your own.
- checklist
boolean- Default
true - Show the checklist under the meter.
- segments
4|5- Default
4 - 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- Default
700 - Milliseconds after typing stops before the strength is announced.
- score
(value, { userInputs }) => StrengthResult- Default
scorePassword - Swap in your own estimate, for example from your server.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | The password being typed. |
| userInputs | string[] | [] | Name, email and the like. A password containing them fails that rule and scores Weak at most. |
| rules | PasswordRule[] | passwordRules() | The checklist. passwordRules({ minLength, mixedCase, number, symbol, notCommon, notPersonal }) builds the usual ones; add { id, label, test } for your own. |
| checklist | boolean | true | Show the checklist under the meter. |
| segments | 4 | 5 | 4 | Meter segments. |
| onGenerate | (password) => void | - | Shows "Generate strong password", then Copy. Fill your field with the value and reveal it. |
| generate | { length?, symbols? } | { length: 20, symbols: true } | Generated passwords use every class and skip look-alikes (0/O, 1/l/I). |
| announceDelay | number | 700 | Milliseconds after typing stops before the strength is announced. |
| score | (value, { userInputs }) => StrengthResult | scorePassword | 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
- 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.
- 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.
- 03Draws 4 or 5 segments with a text label, and exposes the meter as role meter with a plain-language valuetext.
- 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 }.
- 05Generates a strong password with crypto randomness through onGenerate, then offers a Copy button for the generated value.
- 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
| State | What moves | Timing |
|---|---|---|
| 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" }).