Password strength
A new-password field with a four-segment meter, a rule checklist with remaining counts and a strength word that morphs up or down.
oxyn add password-strength- Met: At least 8 characters
- Met: An uppercase letter
- Met: A lowercase letter
- Met: A number
- Met: A symbol
rsx! {
PasswordStrength {
label: "New password",
short_length: 8,
on_change: move |(pw, level): (String, String)| draft.set(pw),
}
}Rendered from Rust at build time · goes live when visible
When to use
- Choosing a new password for an account or a workspace secret.
- The user wants to see, as they type, what's missing and when it's good enough.
When not to use
- A password input whose reveal button slashes the eye with a drawn line, with a Caps Lock warning and a reveal that hides itself again: use Password field instead.
- One input for every form: use Text Field instead.
- On or off for things that apply right away: use Switch instead.
Installation
Password strength is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add password-strengthuse crate::oxyn::{PasswordStrength, PRIMITIVES_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{PasswordStrength, PRIMITIVES_CSS};
Usage
rsx! {
PasswordStrength {
label: "New password",
short_length: 8,
on_change: move |(pw, level): (String, String)| draft.set(pw),
}
}Examples
Checklist
Meter and rules.
- Met: At least 8 characters
- Met: An uppercase letter
- Met: A lowercase letter
- Met: A number
- Met: A symbol
Code
rsx! {
PasswordStrength {
label: "New password",
short_length: 8,
on_change: move |(pw, level): (String, String)| draft.set(pw),
}
}Too short
Holds at the first step.
- Not met: At least 8 characters · 5 more
- Not met: An uppercase letter
- Met: A lowercase letter
- Not met: A number
- Not met: A symbol
Code
rsx! {
PasswordStrength {
label: "New password",
short_length: 8,
on_change: move |(pw, level): (String, String)| draft.set(pw),
}
}Strong
All rules met.
- Met: At least 8 characters
- Met: An uppercase letter
- Met: A lowercase letter
- Met: A number
- Met: A symbol
Code
rsx! {
PasswordStrength {
label: "New password",
short_length: 8,
on_change: move |(pw, level): (String, String)| draft.set(pw),
}
}Nist
Length and not common, no composition (Oxyn plus).
- Met: At least 8 characters
- Not met: Not a common password
- Met: No spaces at either end
Code
rsx! {
PasswordStrength {
label: "New password",
policy: "nist",
short_length: 8,
on_change: move |(pw, level): (String, String)| draft.set(pw),
}
}Meter only
Meter with entropy (Oxyn plus).
Code
rsx! {
PasswordStrength {
label: "New password",
variant: "meter",
entropy: true,
short_length: 8,
on_change: move |(pw, level): (String, String)| draft.set(pw),
}
}API reference
PasswordStrength
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | String | — | Label. |
value | String | Default::default() | Starting value. |
policy | String | "basic" | `basic` · `nist` · `enterprise`. |
short_length | usize | 8 | Below this many characters the meter reads `Too short`. |
error | Option<String> | Default::default() | Error (shakes the field once per new error). |
revealed | bool | Default::default() | Start revealed. |
variant | String | "checklist" | `checklist` (meter + rules) · `meter` (meter only). |
entropy | bool | Default::default() | Show the entropy estimate. |
meter_label | String | "Password strength" | Meter name. |
disabled | bool | Default::default() | Disabled. |
on_change | EventHandler<(String, String)> | — | Changed: the value and its level id. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| EnterorSpace | On the reveal button: show or hide |
Accessibility
- The meter is role=meter, aria-valuenow 0–4 and aria-valuetext set to the word.
- The rule list is linked to the input with aria-describedby, each rule says Met / Not met.
- A status region summarises strength and rules met.
From the spec
The meter is role=meter with aria-valuemin=0, aria-valuemax=4, aria-valuenow and aria-valuetext set to the word. The rule list is linked to the input with aria-describedby; each rule carries hidden "Met:" / "Not met:". A polite status line: "Good, 4 of 5 rules met". Colour is never alone: the word and ticks carry the same meaning.
Motion & interaction
Segments fill in a 60 ms staggered wave toward the new level (reversed when it drops). The strength word morphs: rises when it improves, drops when it gets worse. Ticks draw on as each rule is met; remaining counts roll.
Timing
| Transition | Duration | Easing | Reduced motion |
|---|---|---|---|
| Segment colour | 220 ms, stagger 60 ms | ease.out | 1 ms, no stagger |
| Word roll | 200 ms, 0.6 em | ease.out | swap |
| Rule tick | 220 ms draw | ease.out | drawn |
| Remaining count | 160 ms roll | ease.out | swap |
| Error shake | 360 ms | damped | none |
Responsive behaviour
- The four segments share the row and shrink with the column.
- Coarse pointers get 16 px input text.
Edge cases (spec)
Length counts code points, so emoji count once. Pasted passwords score at once. Leading or trailing spaces fail the NIST edge-space rule. The common list is a small built-in set; real breach checks belong to the host (k-anonymity API). Narrow columns: the four segments share the row.
Notes for AI
- Import
PasswordStrengthfromoxyn_dioxusand includePRIMITIVES_CSSplus the token stylesheet once. - A GPUI version exists:
PasswordStrengthElinoxyn_gpui. - Props to set first:
label. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.