Skip to content

Password Field

Our Input for passwords: a show/hide toggle, a Caps Lock warning, and autocomplete for sign-in or a new password.

On this page
Used for
  • Sign-in form
  • Create an account
  • Rotate an API login
  • Confirm before deleting

Examples

Installation

npx knowns-ui@latest add password-field
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

purpose
"current" | "new"
Default"current"
Sets autocomplete to current-password (sign-in) or new-password (sign-up, change password).
revealed / defaultRevealed / onRevealedChange
boolean
Defaultfalse
Whether the value is shown. The eye button is a toggle with aria-pressed.
capsLockWarning
boolean | ReactNode
Defaulttrue
A "Caps Lock" chip in the field while it is on, also announced to screen readers. Pass text to change it, false to hide it.
autoComplete
string
Overrides the token from purpose.
size / invalid / disabled / ...
Input props
Everything else goes to Input. Inside a Field, label, hint, error and required are wired for you.

Caps Lock is read from key events, so the chip shows after the first key press and clears on blur. Some mobile keyboards don't report it; the chip just stays hidden there. Spell check, auto-capitalise and auto-correct are off.

What it handles

  1. 01Wraps Input with type password and an eye button that shows or hides the value, exposed as aria-pressed.
  2. 02Sets the autocomplete token from purpose: current-password for sign-in and new-password for sign-up, so password managers fill the right thing.
  3. 03Shows a Caps Lock chip while the key is on, read from getModifierState on key down and key up, and clears it on blur.
  4. 04Announces the Caps Lock state through a status region that is always in the DOM, and adds its id to aria-describedby while it shows.
  5. 05Takes revealed, defaultRevealed and onRevealedChange, so the show state can be controlled from outside.
  6. 06Turns off autocapitalize, autocorrect and spellcheck, and accepts every Input prop such as size, invalid and trailing.

States

First render
Nothing. The field paints hidden unless defaultRevealed is set
none
Caps Lock on
The Caps Lock chip pops in inside the field
120ms, ease out
Caps Lock off or blur
The chip is removed
none, at once
Reveal toggle
The value switches between dots and text
none, at once
Reduced motion
The chip appears without the pop
0ms

Works with

When to use

When to use

  • Sign-in, sign-up and change-password fields: show/hide, a Caps Lock warning and the right autocomplete.

When not to use

  • One-time codes from email or SMS: use OTP Input.
  • API keys you show once and copy: use Input.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Password Field to my app and wire it to my own data.
  • I need sign-in, sign-up and change-password fields: show/hide, a Caps Lock warning and the right autocomplete. Set that up with the Knowns UI Password Field.
  • Which Password Field props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "password-field" }) and search_docs({ query: "password field" }).

Need help?

Stuck on Password Field, or found something off? We read every message.