#842
Your own rule
A strength meter driven by your own length rule, with custom label text.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "Your own rule" pattern (@codeatlasdev/ui demo #842, inputs/password-strength) in my app.
Call get_demo({ ids: ["#842"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Apps whose password policy is length-based or comes from a server rule.
Keep these library parts, with the props and tokens the demo uses:
- PasswordStrength, TextField from "@codeatlasdev/ui"
Behaviour to keep:
- `const byLength = (v: string) => (v.length === 0 ? 0 : v.length >= 12 ? 3 : v.length >= 8 ? 2 : 1)`
- `value={password}` and `score={byLength}` on `<PasswordStrength`
- `labels={{ empty: 'Type a passphrase', weak: 'Too short', fair: 'Almost there', strong: 'Good length' }}`
- Field is `<TextField label="Passphrase" type="password" bind:value={password} />`
Reduced motion: the demo handles it; keep that branch.
Keyboard: operable; keep the focus order and key handling.
Change only the copy and the data. Use the theme tokens (--ca-*), never raw colours. Library parts
- PasswordStrength
@codeatlasdev/ui - TextField
@codeatlasdev/ui
How it is built
- `const byLength = (v: string) => (v.length === 0 ? 0 : v.length >= 12 ? 3 : v.length >= 8 ? 2 : 1)`
- `value={password}` and `score={byLength}` on `<PasswordStrength`
- `labels={{ empty: 'Type a passphrase', weak: 'Too short', fair: 'Almost there', strong: 'Good length' }}`
- Field is `<TextField label="Passphrase" type="password" bind:value={password} />`
Related
Loading source.