Skip to content
Hazine

Password Input

Password field with a show and hide toggle at the end and an optional four step strength meter with a word. Supports controlled and uncontrolled value.

How it differs. Baseline masked field with a single visibility toggle inside the field and an opt-in strength meter under it, with no rule checklist.

Install

pnpm dlx shadcn@latest add @hazine/password-input

Adds 1 file, 1 shadcn primitive (input), 1 Hazine item (@hazine/use-controllable-state), 1 package (lucide-react), and the success and warning tokens.

First time? Add the registry to components.json
{
  "registries": {
    "@hazine": "https://api.hazine.dev/r/{name}.json"
  }
}

Needed once per project. Items resolve each other through the @hazine namespace.

Props6

value
string
defaultValue
string = ""
onValueChange
(value: string) => void
showStrength
boolean = false
Shows a four step strength meter with a word under the field.
toggleLabel
string = "Show password"
Accessible name of the visibility toggle. It does not change when pressed.
strengthLabel
string = "Password strength"
Text before the strength word, for example "Password strength".

Also accepts every prop of Omit< React.ComponentProps<typeof Input>, "type" | "value" | "defaultValue" >.

Accessibility

Pattern
Form with labelled fields, Button (APG, opens in a new tab)
Keyboard
Keyboard support for Password Input
KeyEffect
TabMoves from the field to the visibility toggle
Enter or Space on the toggleShows or hides the password and keeps focus on the toggle
Screen reader

A native input the consumer labels. The toggle is a button with aria-pressed and aria-controls, and the strength word sits in a status region linked by aria-describedby.

  • Announces: Password strength: {word}
Reduced motion
No motion. Colour transitions only.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies3

  • input
  • @hazine/use-controllable-state
  • lucide-react

Filled chips are registry items the CLI adds for you. Outlined chips are npm packages.

Tokens shipped4

  • --success
  • --success-foreground
  • --warning
  • --warning-foreground

Added to your stylesheet in light and dark, unless you already define them.

More in Text Inputs