Skip to Content
zjkm-ui
Components

Password Input

A password field with show and hide, and a strength meter.

Use 8 or more characters with a mix of letters, numbers and symbols.
Props
<PasswordInput />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/password-input.json
import { PasswordInput } from "@/components/password-input"

Using JavaScript? Set tsx: false in components.json and the CLI converts it.

New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.

Usage

A password field with a Show/Hide button and a four-bar strength meter. The strength is also written out in words and linked to the field, so screen readers hear it too.

import { PasswordInput } from "@/components/password-input";

export function NewPassword() {
  return <PasswordInput label="Password" name="password" autoComplete="new-password" />;
}

The score is a simple guide: a point for 8 or more characters, then one each for mixed case, a digit and a symbol. passwordScore is exported if you want it elsewhere. Check passwords on your server too.

Props

PropTypeDefaultDescription
labelstringThe label.
showStrengthbooleantrueShows the meter and the strength in words.
classNamestringClasses for the wrapper.
...propsinput propsEvery native <input> prop: name, required, onChange and so on.

It has no animation, so reduced motion changes nothing.

On this page