Ajouter

Lorem ipsum

Lorem ipsum

CRO / Conversion

5 views

3 min

How to Show or Hide a Password in a Webflow Input

Learn how to add a show/hide password button to a Webflow field with JavaScript.

In this tutorial, Sandro, cofounder of Gemeos Webflow agency, shows you how to add a show/hide button to a password field in Webflow.

Example

ElementClassRole
Password inputpassword-inputInput field (type=password)
Toggle buttonpassword-toggleEye button next to the field
Visible iconicon-showSVG or text 'Show'
Hidden iconicon-hideSVG or text 'Hide'

1. Build the structure in Webflow

Create a Div containing a Password input (class password-input) and a button (class password-toggle) side by side. Position the button absolutely on the right of the input if needed.

2. The script

document.querySelectorAll('.password-toggle').forEach(function(toggle) {
var input = toggle.closest('div').querySelector('.password-input');
if (!input) return;
var show = toggle.querySelector('.icon-show');
var hide = toggle.querySelector('.icon-hide');
if (hide) hide.style.display = 'none';

toggle.addEventListener('click', function() {
var isPassword = input.type === 'password';
input.type = isPassword ? 'text' : 'password';
if (show) show.style.display = isPassword ? 'none' : 'block';
if (hide) hide.style.display = isPassword ? 'block' : 'none';
});
});

Simplified version (text only)

If you just want a text link "Show / Hide" without icons:

document.querySelectorAll('.password-toggle').forEach(function(toggle) {
var input = toggle.closest('div').querySelector('.password-input');
toggle.addEventListener('click', function() {
var isPass = input.type === 'password';
input.type = isPass ? 'text' : 'password';
toggle.textContent = isPass ? 'Hide' : 'Show';
});
});

good to know

Add aria-label='Show password' to your toggle button for accessibility. Update the aria-label dynamically in the script based on the state (Show/Hide). Screen readers will announce the available action, making the form accessible to blind users.

Conclusion

The password toggle improves UX on every password form. It’s essential on mobile, where typing is more error-prone.

Published on

You might be interested in these tutorials

Similar tutorials

SEO / GEO

5 min read

5 views

How to Set Up a Redirect in Webflow? (2026)

Updated on 19.12.2025 by Sandro DA SILVA

SEO / GEO

5 min read

5 views

Add structured data to your Webflow site?

Updated on 21.08.2025 by Sandro DA SILVA

No-code

5 min read

5 views

How to Obfuscate a Link in Webflow

Updated on 23.04.2025 by Sandro DA SILVA

Let’s f*****G GO !!

Ready to launch
Your business?

Alexandre

Max

Enora

Bryan

Cannelle

Tiphaine

You'll :heart: our collaboration...