Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Password Input

A password field with a button that shows or hides what was typed.

Built on the headless Password Input.See its API in Docs

Rendered by React 19.3.1

password-input.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/password-input.json

It also adds utils, button. The app needs its setup first: Installation.

Usage

Put a PasswordInputInput and a PasswordInputToggle inside a PasswordInput. The Toggle draws a PasswordInputIndicator with an eye while the password is hidden and a crossed eye while it is shown, unless it has content of its own. Name the field with a Field label or aria-label; the Toggle is named "Show password" and states whether the password is shown with aria-pressed. Visibility is defaultVisible or visible with onVisibleChange on the Root, and the Input and the Toggle take disabled from the Root or a Field. Inside a form, the password is hidden again on submit, on reset and when the page is restored from the back-forward cache. The caret and the selection, the focus rule and the autofill attributes come from the headless Password Input.

import {
  PasswordInput,
  PasswordInputIndicator,
  PasswordInputInput,
  PasswordInputToggle,
} from '@/components/ui/password-input'

Examples

Default

A labelled password field with the Toggle at its end.

Its preview and code are at the top of the page.

The Input is the Input's with pe-10 at its end so the text never runs under the Toggle, and without the reveal button Edge adds to a password field (::-ms-reveal). The Toggle is the Button's ghost variant at the 24px icon-xs size, centered at the end of the Root, and stays a tab stop. This item takes Base UI's component ID as its slug and one name per Base UI part; shadcn has no password input.

API reference

The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Password Input's API reference.