PasswordInput
FrondInput with a show and hide toggle once there's a value. Same rules as Input.Usage
The import, then a use to start from. Both copy as they are.
Import
import { Label } from "@/components/ui/label";import { PasswordInput } from "@/components/ui/password-input";Example
<div className="flex flex-col gap-2"> <Label htmlFor="api-key">API key</Label> <PasswordInput id="api-key" value={apiKey} onChange={(event) => setApiKey(event.target.value)} /></div>When to use
Use it for
- Any secret a person types or pastes: API keys, tokens, passwords. The toggle appears once there's a value.
- Everything else follows
Input: a visibleLabel,aria-invalidfor errors, help text tied byaria-describedby. containerClassNamesizes the wrapper (flex-1, widths);classNamestyles the input itself.
Avoid
- An
Inputwithtype="password"and a hand-built toggle. - A secret only shown once, like a newly created token: show it in a
CopyableTextand say it won't be shown again.
Accessibility
Checks
- The toggle is a labeled button (Show password, Hide password), so its state is announced.
- Revealing only changes the field's type; focus and the value stay where they are.
API
Read from each component's stories, the same source as COMPONENTS.md, and kept in step by check:design-system.
PasswordInput
Its stories don't declare
argTypes, so no props are listed. The variants show its states.VariantsDefaultWithValueRevealedReadOnlyDisabled
Keep going
- Input, TextareaText entry. Always with a
Label; errors viaaria-invalidand aNote.Frond - CopyableText, CodeSnippetValues a user copies: commands, keys, URLs.Fiddle
Patterns
How components come together into pages.