- Add the registry
- Add password-input
Usage
Password Input is an Input with an eye button at its end that switches the
input between type="password" and type="text". Like Secret Field's,
the button is a toggle that's pressed while the password is shown, so its label, revealLabel,
stays "Show password" in both states.
Password Input takes every prop Input does except type, including size and variant. The button
matches the input's size, variant and disabled state, including the disabled state of a
Field. className, style and render are applied to the wrapper around the
input and the button, and every other prop is passed to the input.
autoComplete tells password managers what to fill. It defaults to current-password, for signing
in. Set it to new-password for signing up or changing a password. Spellcheck, autocorrect and
autocapitalization are turned off, so a shown password isn't sent to a spellchecker or altered as
it's typed.
A shown password is hidden again when someone presses Escape, moves focus elsewhere on the page,
or submits or resets the form. This keeps it from being left on screen, or submitted from a type="text" input,
which password managers can miss. Switching to another window leaves it shown.
To show a secret that users can't edit, such as an API key, use Secret Field.
Examples
New password
Use at least 12 characters.
Controlled
revealed and onRevealedChange control whether the password is shown, here for two fields at
once. eventDetails.reason says why the state changed, and canceling a "focus-out" change keeps
both passwords shown as focus moves between the fields.
Sizes
Invalid
Disabled
Props
Base UI's styling (opens in a new tab) and composition (opens in a new tab) guides say more about className, style and render.