Skip to content

Password Field

Free

A password field with an eye button that shows or hides the text, and a hint when Caps Lock is on. It hides the password again on submit.

  • Base UI
  • React 19
  • Tailwind CSS 4

Added Nov 8, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Put PasswordFieldInput and PasswordFieldToggle in PasswordField, inside a Field. Pass autoComplete="new-password" on a sign-up form.

The sample also uses Field. One command adds them with this item:

sign-in-password.tsx

PasswordField

<div>
PropTypeDefaultDescription
rounded"default""full"—
size"default""lg""sm""xs"—
variant"dashed""default"—
classNamestring—
visibleboolean—Shows the password as text (controlled).
defaultVisiblebooleanfalseShows the password as text at first (uncontrolled). Default false.
onVisibleChange—Runs when the toggle, a form submit, or a page hide changes visible.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

PasswordFieldInput

<input>
PropTypeDefaultDescription
classNamestring—
rounded"default""full"—
size"default""lg""sm""xs"—
From Base UIInputBase UI docs
onValueChange—Callback fired when the value changes. Use when controlled.
defaultValuestring | number | readonly string[]—The default value of the input. Use when uncontrolled.
valuestring | number | readonly string[]—The value of the input. Use when controlled.
...props<input> attributes—Every other attribute goes to the <input>, with a ref.

PasswordFieldToggle

<button>
PropTypeDefaultDescription
classNamestring—
size"icon-sm""icon-xs""sm""xs"—
rounded"default""full"—
variant"dashed""default""destructive""destructive-outline""ghost""link""media""outline""secondary"—
labelstring"Show password"The name of the toggle. Default "Show password". It does not change with the state.
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
style—Style applied to the element, or a function that returns a style object based on the component's state.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

PasswordFieldCapsLock

<output>
PropTypeDefaultDescription
...props<output> attributes—Every other attribute goes to the <output>, with a ref.
  • Use it for each password in a sign-in, sign-up, or change form.
  • Use PasswordFieldToggle so people can check what they typed.
  • Use PasswordFieldCapsLock in the same Field to show a Caps Lock hint.
EnterorSpaceOn PasswordFieldToggle: shows or hides the password. Focus stays on the toggle.

The toggle name stays "Show password" in both states, and it uses aria-pressed.

The field goes back to hidden on submit, page hide, and unmount, so a browser never keeps a shown password.

The toggle is disabled with the input, so Tab skips it in a disabled field.

Built with

Installs with Password Field

Components
Input Group
  1. AddedPassword Field, with Input Group.
Open the release