Password Field
A password input with a toggle that reveals the typed value.
Usage guidelines
- Use
PasswordFieldfor a password the user types and may reveal to check. It renders theInputGroupsurface, so its border, focus, invalid and disabled visuals match every other grouped input. - Set
autoCompleteonPasswordFieldInput; the types require it. Usecurrent-passwordfor an existing password andnew-passwordfor a password being set, so password managers fill or suggest the right value.PasswordFieldInputownstype. - Wrap the field in
Fieldwith aFieldLabelfor the label, validation and errors. PasswordFieldToggleis optional. Give it anaria-labelthat stays the same in both states;aria-pressedreports whether the value is revealed. It is atype="button"button, so it never submits the form. Pressing it with a pointer keeps focus in the input, and it stays available while the input is read-only.- Set
disabledonPasswordFieldto disable both the input and the toggle, and on the surroundingFieldsoFieldLabelreceivesdata-disabledas well. A disabledFieldalone reaches only the input. - Keep
PasswordFieldfor the user's own account password. Credentials for other services, such as API keys, tokens and database passwords, useInputwithtype="password"andautoComplete="off":current-passwordinvites the browser to fill the account password into them, andnew-passwordmakes it suggest a generated one. Some password managers ignoreautoComplete="off"on masked inputs, so keep these fields out of sign-in and password forms. - Ask for a new password once. The reveal toggle lets the user check what they typed, so a second "confirm password" input is unnecessary.
Anatomy
The anatomy mirrors the upstream Base UI Password Field preview. The reveal behavior is a local implementation until Base UI ships the primitive; the parts then wrap it without changing call sites.
Examples
In a form
A password change form asks for the current password and one new password. A hidden username input tells password managers which account the new password belongs to. Native constraints and validate drive the field errors, which appear when the form is submitted and then update as the value changes. The submit button shows loading while the request runs and ignores repeated submits. A rejected current password comes back through Form errors and shows in the FieldError without match; enter incorrect as the current password to see it.
Read-only and disabled
A read-only temporary password can still be revealed. Setting disabled on both Field and PasswordField disables the label, input and toggle together, and the description says why.
Share it with the new member. It expires in 24 hours.
Your workspace requires single sign-on.
Tokens and API keys
A model provider key is masked with Input and type="password". autoComplete="off" asks the browser not to fill a saved password into it or suggest a generated one.
Stored encrypted and used only for this workspace.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves focus from the input to the toggle. |
| EnterorSpace | Reveals or masks the value when the toggle has focus. |
API reference
PasswordField
A compound password input with a built-in visibility toggle on the InputGroup surface. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
disabled | boolean | false | |
PasswordFieldInput
The password input inside PasswordField; requires autoComplete ('current-password' or 'new-password'). Renders an <input> element.
| Prop | Type | Default | Details |
|---|---|---|---|
autoComplete required | 'current-password' | 'new-password' | No default | |
className | string | ((state: InputState) => string | undefined) | No default | |
style | React.CSSProperties | ((state: InputState) => React.CSSProperties | undefined) | No default | |
onValueChange | ((value: string, eventDetails: BaseInput.ChangeEventDetails) => void) | No default | |
defaultValue | string | number | readonly string[] | No default | |
value | string | number | readonly string[] | No default | |
| Attribute | Description |
|---|---|
data-disabled | Present when the input is disabled. |
data-valid | Present when the input is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the input is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the input has been touched (when wrapped in Field.Root). |
data-dirty | Present when the input's value has changed (when wrapped in Field.Root). |
data-filled | Present when the input is filled (when wrapped in Field.Root). |
data-focused | Present when the input is focused (when wrapped in Field.Root). |
PasswordFieldToggle
An inline-end add-on containing an icon button that toggles password visibility; requires aria-label. Renders a <div> element containing a <button>.
| Prop | Type | Default | Details |
|---|---|---|---|
aria-label required | string | No default | |
disabled | boolean | false | |