Password Input
A password field with a show/hide toggle, composed from InputGroup.
- Status
- 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-inputInstall with the pinned shadcn CLI. Bare shadcn does not verify VegaStack signature or integrity.
pnpm dlx shadcn@4.21.0 add @vegastack/password-inputRun 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
| Prop | Type | Default | Description |
|---|---|---|---|
hideLabel | string | 'Hide password' | Accessible name of the toggle while the password is visible. |
showLabel | string | 'Show password' | Accessible name of the toggle while the password is hidden. |
Data attributes and CSS variables on PasswordInput
| Attribute | Values |
|---|---|
data-slot | "password-input" | "password-input-toggle" |
Accessibility
- Name the field with a
FieldLabel,aria-label, oraria-labelledby. - The toggle is a
type="button"icon button, so it never submits the form. It is namedShow passwordorHide passwordand reports its state witharia-pressed; override the names withshowLabelandhideLabel. - Tab moves from the input to the toggle; Enter or Space toggles it.
| Contract | States tested |
|---|---|
| Behaviour | hidden, revealed, disabled, invalid |
| Accessibility | native-password-semantics, browser-accessibility-test, labeled, pressed-toggle, disabled, invalid |
| Visual | default, hover, focus, disabled, invalid |