Skip to content
Haze UI

Password strength

A new-password field with a four-part meter, a live count and a checklist that explains every filled segment.

pnpm dlx shadcn@latest add @haze/password-strength
Open preview in a new tab
Livesmall script

When to use

  • A signup or password-change form needs to show which character rules are met as the user types.
  • A visible count and individual criteria help people revise a proposed password.

When not to use

  • A returning user is signing in. Use password-input.
  • A server needs to detect compromised credentials or enforce a password policy.

Installation

Add the Haze registry to components.json once, then install Password strength with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/password-strength
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–ID of the password input and prefix for its rule and error descriptions.
namestringidName submitted by the native password field.
labelstringNew passwordVisible field label.
lengthTargetnumber12Minimum number of Unicode code points for the length check. The other checks recognize mixed case, a decimal digit and punctuation or a symbol.
autocompletestringnew-passwordNative autofill hint.
required / disabledboolean–Native required and disabled states.
errorstring–External validation message associated with the input.
toggleLabelstringShow passwordAccessible name of the visibility toggle.
classstring–Classes applied to the wrapper.
...attributesHTML input attributes–Additional native attributes, including form, value and maxlength. Caller descriptions are combined with the checklist.

Keyboard interactions

EnterSpace
Toggle visibility when the reveal button has focus.

Accessibility

  • Each displayed rule has an audible met or pending state. The meter announces changes to the total.
  • Without scripting, the labelled password field and its written criteria remain available.
  • The segment fills and check marks update immediately when reduced motion is requested.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Password strength" with `npx shadcn@latest add @haze/password-strength`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import PasswordStrength from "@/components/haze/ui/password-strength.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/password-strength.md

  • Customize with real content

    Adapt the Haze password-strength ui for our product. Replace the demo values of these props with our real content: id, name, label, lengthTarget, autocomplete, required / disabled, error, toggleLabel, class, ...attributes. Keep the layout, the heading level rules and these accessibility details: Each displayed rule has an audible met or pending state. The meter announces changes to the total. Without scripting, the labelled password field and its written criteria remain available. The segment fills and check marks update immediately when reduced motion is requested. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using password-strength, check it fits: use it when a signup or password-change form needs to show which character rules are met as the user types.; a visible count and individual criteria help people revise a proposed password.. Avoid it when a returning user is signing in. use password-input.; a server needs to detect compromised credentials or enforce a password policy.. Alternatives: @haze/password-input, @haze/input, @haze/progress.

Dependencies

  • npm: @lucide/astro
  • @haze/label
  • @haze/password-input
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog