PasswordInput

A password field with the show/hide eye.

$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/password-input.json

States

48 field, the eye at the right (ghost IconButton 36, 44 hit area). Hidden by default; the eye shows the value (eye ↔ eye-off, 09 Icon swap, pressed = grey, aria-pressed, "Tampilkan password" / "Sembunyikan password"). No timer; the screen hides it again on submit (resetKey). No placeholder: a password has no example value. Invalid: the Input error ring + FieldError under it.

Password terlalu pendek. Pakai minimal 8 karakter.

When to use

  • Every password field: Masuk ("Password", current-password), Undangan ("Password baru", "Ulangi password", new-password), later "Ubah password".

When not to use

  • Any other secret that is not typed by the user (a PIN shown once) → plain text, not this field.
  • A one-time code → Input with inputMode="numeric" and autoComplete="one-time-code".

Do and don't

DoSet autoComplete"current-password" to sign in, "new-password" for both fields of a new password, so a password manager fills and saves the right thing.
Don'tA placeholder like "Masukkan password"The label already says what to type. Placeholders show example values only (docs/writing.md).

Installation

Add PasswordInput with the shadcn CLI (your project needs a components.json and the MaHR theme: https://mahrdesign.faizintifada.com/r/theme.json), or copy the files by hand.

terminal
bunx --bun shadcn@latest add https://mahrdesign.faizintifada.com/r/password-input.json

API

import { PasswordInput } from "@/components/ui/password-input"
PropTypeDefaultDescription
…Input propsInputProps (no type, no end)–value, onChange, id, name, aria-invalid, aria-describedby, size, disabled.
autoCompletestring"current-password""new-password" on a page that creates one.
shown · defaultShown · onShownChangeboolean · boolean · (shown) => void–Controlled or uncontrolled eye.
resetKeynumber | string–Change it (e.g. the submit count) to hide the value again.