Password Input

Warns about Caps Lock, a non-Latin keyboard layout and pasted spaces as they happen, so a typo doesn't look like a wrong password.

StopsLockout caused by Caps Lock

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/password-input.json

The files land in your project. They're yours to edit.

Usage

password-input-usage.tsx
import { PasswordInput } from "@/components/ui/password-input"

<PasswordInput label="Password" defaultValue="Ызкштп2026" />

What it catches

  • Caps Lock on
  • Non-Latin keyboard layout producing other characters
  • Pasted leading or trailing spaces, with a one-tap trim
  • Typing blind: peek to check

Props

PasswordInput props
PropTypeDefault
label

Visible label.

string"Password"
hint

Helper text shown under the field while there is nothing to warn about.

string—
value

Controlled value.

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the new value on every change.

(value: string) => void—
capsLockMessage

Warning shown while Caps Lock is on.

string"Caps Lock is on."
trimLabel

Label of the one-tap fix that trims a pasted password.

string"Trim spaces"
peekLabel

Accessible label of the peek button.

string—
peek

`hold` shows the password only while the eye is pressed (safest on a shared screen); `toggle` flips it like most sign-in forms.

"hold" | "toggle""hold"
layoutMessage

Layout warning when the pressed key is known, e.g. "Q gave й".

(script: string, pressed: string, typed: string) => React.ReactNode(script, pressed, typed) => ( <> Your keyboard is typing …
scriptMessage

Layout warning when only the letters are known (pasted or autofilled).

(script: string) => string(script) => `The password contains ${script} letters. Is …
spaceMessage

Warning for a pasted password with spaces at its `start`, `end` or `both`.

(where: "start" | "end" | "both") => string(where) => `The pasted password ${where === "both" ? "sta…

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Visible label; input is described by the hint and warnings
  • Peek button has an aria-label, aria-pressed and title; hold works with Space or Enter
  • Focus returns to the input after a fix

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: Rate-limit sign-in attempts on the server; these warnings only reduce honest mistakes.

  • Caps Lock state is only known after a key event
  • Doesn't check strength or breaches; see Password Policy Input

What it stops

Lockout caused by Caps Lock

Also known as

password · login · sign in · caps lock · show password · password field · auth form · signup

Field type

Dependencies

Pairs well with