Forms & Inputs
Password Input
A password field with a built-in reveal toggle and wired-up error messaging.
A password field with a reveal toggle built in.
Import
tsx
1import { PasswordInput } from "@yuhuanowo/yunui";Usage
It forwards every <input> attribute, so it drops into a form exactly where a plain <Input type="password"> would — controlled or uncontrolled, with name, autoComplete, required and the rest.
Password input
Passwords do not match.
Notes
- The toggle is a flex sibling of the input, not an absolutely-positioned overlay. Safari mis-placed the absolute version outside the field; the flex row renders identically everywhere.
- The toggle is
tabIndex={-1}, so tabbing through a sign-in form goes password → submit, without a detour through a button that only changes what you can see. - It carries
aria-pressedand a label that flips between show/hide — override the English defaults withlabels={{ show, hide }}. errorsetsaria-invalidand links the message witharia-describedby.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| error | string | — | Error message shown below the field; also switches the border to a red error style. |
| labels | { show?: string; hide?: string; } | undefined | — | Accessible labels for the reveal toggle (English defaults). |