Password Input
An input for passwords and other sensitive values, with a built-in button that shows or hides the value. Pair it with Field to connect its label, description, and errors in a form.
When to use
- Password fields on login, signup, and reset flows.
- One-time tokens, recovery codes, or secrets the user must type accurately and may want to check visually before submitting.
- Prefer
Inputwhen the value is never sensitive, or when the toggle would confuse the user, such as with masked formatting for phone numbers. - Prefer
OtpInputwhen the value is a one-time passcode with one box for each character.
Validation
Set validation to show the validation status of the input.
Without a Field
Render the control on its own, and give it an accessible name with aria-label.
Visibility state
PasswordInput renders a native <input type="password"> with a trailing button. The button toggles the display between hidden (••••) and revealed (text).
The toggle is uncontrolled by default. Pass showValue to control the visibility from the outside, for example when one control reveals several password fields. Pass onValueVisibilityChange to receive the next visibility when the user clicks the built-in toggle. The eye icon animates on every visibility change, from the built-in toggle or from showValue, unless the user prefers reduced motion.
Accessibility
Always pair with a Label. The toggle is a focusable button with aria-pressed, named "Show value". The name does not change with state and does not contain the word "password", so a label query for the input matches one element. Its aria-controls points at the input's id: the id you pass, else a generated one. When disabled is set, the toggle is disabled too, so Tab skips the component. The input keeps autocomplete="current-password" / "new-password" semantics. Set autoComplete explicitly per flow.
Inside a Field.Item, pass id on Field.Item to set the input's id yourself, for example for a Playwright locator: Field.Label, the input, and the toggle's aria-controls all follow it.
Browser password managers
When revealed, the input switches to type="text". Some password managers may pause autofill in this state, which is the intended security trade-off.
Examples
With TanStack Form
Use @tanstack/react-form with zod to validate a controlled PasswordInput inside Field.Item.
API Reference
PasswordInput
The PasswordInput accepts the following props in addition to the standard HTML input attributes, except type: the toggle owns it.
One standard attribute is narrowed to a union, so a typo is a type error: autoComplete accepts the HTML autocomplete tokens.