How to build an accessible PasswordInput in React

The reveal control is a real <button> whose aria-label switches between reveal/hide so screen-reader users know the current masking state; toggling swaps the input type between password and text so the platform handles masking natively.

When to use a PasswordInput

When not to use it

Keyboard interactions

Role textbox, verified at WCAG 2.2-AA.

Common mistakes

Avoid: <Input type="password" />

Prefer: <PasswordInput showStrengthMeter />

PasswordInput adds an accessible reveal/hide toggle and an optional strength meter on top of the masked field, which a raw password input lacks

Example

<PasswordInput placeholder="Enter password" />

See the full PasswordInput reference →