Skip to content
Back

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
MCP
Strong
  • Met: At least 8 characters
  • Met: An uppercase letter
  • Met: A lowercase letter
  • Met: A number
  • Met: A symbol
Strong, 5 of 5 rules met
Dioxus
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.

Terminal
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add password-strength
Rust
use 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

Dioxus · rust
rsx! {
    PasswordStrength {
        label: "New password",
        short_length: 8,
        on_change: move |(pw, level): (String, String)| draft.set(pw),
    }
}

Examples

Checklist

Meter and rules.

Strong
  • Met: At least 8 characters
  • Met: An uppercase letter
  • Met: A lowercase letter
  • Met: A number
  • Met: A symbol
Strong, 5 of 5 rules met
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.

Too short
  • 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
Too short, 1 of 5 rules met
Code
rsx! {
    PasswordStrength {
        label: "New password",
        short_length: 8,
        on_change: move |(pw, level): (String, String)| draft.set(pw),
    }
}

Strong

All rules met.

Strong
  • Met: At least 8 characters
  • Met: An uppercase letter
  • Met: A lowercase letter
  • Met: A number
  • Met: A symbol
Strong, 5 of 5 rules met
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).

Weak
  • Met: At least 8 characters
  • Not met: Not a common password
  • Met: No spaces at either end
Weak, 2 of 3 rules met
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).

Strong
≈ 66 bits
Strong, 5 of 5 rules met
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

PropTypeDefaultDescription
labelrequiredString—Label.
valueStringDefault::default()Starting value.
policyString"basic"`basic` · `nist` · `enterprise`.
short_lengthusize8Below this many characters the meter reads `Too short`.
errorOption<String>Default::default()Error (shakes the field once per new error).
revealedboolDefault::default()Start revealed.
variantString"checklist"`checklist` (meter + rules) · `meter` (meter only).
entropyboolDefault::default()Show the entropy estimate.
meter_labelString"Password strength"Meter name.
disabledboolDefault::default()Disabled.
on_changeEventHandler<(String, String)>—Changed: the value and its level id.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
EnterorSpaceOn 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
TransitionDurationEasingReduced motion
Segment colour220 ms, stagger 60 msease.out1 ms, no stagger
Word roll200 ms, 0.6 emease.outswap
Rule tick220 ms drawease.outdrawn
Remaining count160 ms rollease.outswap
Error shake360 msdampednone

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 PasswordStrength from oxyn_dioxus and include PRIMITIVES_CSS plus the token stylesheet once.
  • A GPUI version exists: PasswordStrengthEl in oxyn_gpui.
  • Props to set first: label.
  • Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI