Skip to content
Component installs need the registry setup
VegaStack Design

Password Input

A password field with a show/hide toggle, composed from InputGroup.

Status
stable
Since
0.14.0
Accessibility pattern
password input with a named, pressed reveal toggle

Last updated

Install

Configure registry credentials first using the Quickstart. Before copying this item or any transitive registry dependency, verify the signed manifest and save the exact bytes for Password Input before installation. Retain the digest printed by this command.

pnpm exec vegastack-design verify password-input

Install with the pinned shadcn CLI. Bare shadcn does not verify VegaStack signature or integrity.

pnpm dlx shadcn@4.21.0 add @vegastack/password-input

Run the exact offline --post-write command printed by the preflight, using its saved item path and independently retained --expected-integrity digest. Use the saved preflight for every transitive registry dependency too; stop on any mismatch before using the components.

The same command installs the registry items it composes: @vegastack/input-group.

Usage

import { Field, FieldLabel } from "@/components/ui/field";
import { PasswordInput } from "@/components/ui/password-input";

<Field>
  <FieldLabel htmlFor="password">Password</FieldLabel>
  <PasswordInput
    id="password"
    name="password"
    autoComplete="current-password"
  />
</Field>;

PasswordInput composes InputGroup with one icon button that switches the field between password and text. className styles the group root; the ref and every native input attribute — id, name, autoComplete, aria-invalid — target the inner HTMLInputElement.

Examples

States

Descriptions, errors and the disabled state come from Field and the shared InputGroup contract.

At least 12 characters.

Inside a Field

Inside a Field the inner <input> takes its label, the rendered description and error ids, and aria-invalid from the Field — no id, htmlFor or aria-describedby to keep in sync.

At least 12 characters.

API Reference

PasswordInput

PropTypeDefaultDescription
hideLabelstring'Hide password'Accessible name of the toggle while the password is visible.
showLabelstring'Show password'Accessible name of the toggle while the password is hidden.

Data attributes and CSS variables on PasswordInput

AttributeValues
data-slot"password-input" | "password-input-toggle"

Accessibility

  • Name the field with a FieldLabel, aria-label, or aria-labelledby.
  • The toggle is a type="button" icon button, so it never submits the form. It is named Show password or Hide password and reports its state with aria-pressed; override the names with showLabel and hideLabel.
  • Tab moves from the input to the toggle; Enter or Space toggles it.
ContractStates tested
Behaviourhidden, revealed, disabled, invalid
Accessibilitynative-password-semantics, browser-accessibility-test, labeled, pressed-toggle, disabled, invalid
Visualdefault, hover, focus, disabled, invalid

Do / Don't

Do
Use PasswordInput for any secret the user types, with the right autoComplete (current-password or new-password).
Don't
Hand-roll an InputGroup reveal toggle, or render a plain Input with type='password' when users need to check what they typed.

On this page