Skip to content
← All articles

Tutorials ·

Build a Password Input with Show/Hide and Strength Feedback in React

UI Layouts

On this page

Password feedback should help users choose a strong password without collecting unnecessary personal information.

Live example from UI Layouts

Must contain:Enter a password

  • At least 8 characters - Requirement not met
  • At least 1 number - Requirement not met
  • At least 1 lowercase letter - Requirement not met
  • At least 1 uppercase letter - Requirement not met
  • At least 1 special characters - Requirement not met

Keep visibility under user control

Use password and text input types for the same controlled value. Label the toggle Show password or Hide password and preserve the caret when feasible.

Treat strength as guidance

Length and common-password screening are more useful than arbitrary composition checkboxes alone. A visual strength meter is not proof that a password is safe.

Validate at the server

Never log the password or send it to an untrusted scoring endpoint. Support password managers and paste, and use an appropriate password hashing system on the server.

Implementation pattern

The following focused snippet demonstrates the principle, not the complete UI Layouts implementation. The live example and linked documentation contain the full source.

<input type={visible ? 'text' : 'password'} autoComplete='new-password' value={password} onChange={e => setPassword(e.target.value)} />

Explore the source

Open the password component documentation for the full implementation, examples and any required dependencies. Test the interaction on a narrow screen and with keyboard navigation before adapting it to production.