Bootstrap: Reveal Password Input

Ruth Jul 09, 2026

In the realm of web development, Bootstrap has emerged as a powerful toolkit for designing responsive and mobile-first websites. One of its many useful features is the ability to create password input fields with a toggleable show/hide functionality. This not only enhances user experience but also aligns with best practices for password security. Let's delve into how you can achieve this with Bootstrap.

Best Free Bootstrap Login Forms » CSS Author
Best Free Bootstrap Login Forms » CSS Author

Before we dive into the code, it's essential to understand why showing and hiding passwords is beneficial. By default, password fields mask the input, preventing shoulder surfing. However, users often need to verify if they've entered their password correctly, especially when dealing with complex password requirements. A show/hide toggle allows users to check their input without compromising their security.

Forget password flow
Forget password flow

Implementing Bootstrap Password Toggle

Bootstrap provides a simple and elegant solution for creating a password toggle using its built-in input group and custom form controls. Here's how you can implement it:

Disney+
Disney+

First, include the necessary Bootstrap CSS and JavaScript files in your project. Then, add the following HTML structure for your password input field:

Basic Setup

an iphone screen showing the settings and options for texting on their phone's screens
an iphone screen showing the settings and options for texting on their phone's screens

Start by creating a Bootstrap input group and add a custom checkbox for toggling the password visibility:

```html

```

Next, add the following JavaScript code to handle the toggle functionality:

JavaScript Functionality

JavaScript Password Strength Checker
JavaScript Password Strength Checker

Use the following JavaScript code to toggle the password field type between 'password' and 'text' based on the checkbox's checked state:

```javascript document.getElementById('show-password').addEventListener('change', function(e) { const passwordField = document.getElementById('password'); passwordField.type = e.target.checked ? 'text' : 'password'; }); ```

With this setup, users can now click the 'Show' label to toggle the password visibility. The input field's type changes accordingly, providing a seamless user experience.

Styling the Password Toggle

Bootstrap Forget Password Form
Bootstrap Forget Password Form

While Bootstrap provides basic styling for input groups, you might want to customize the appearance of your password toggle to match your website's design. Here's how you can style the toggle using Bootstrap's utility classes and custom CSS:

Using Bootstrap Utility Classes

the text message is being displayed on an iphone's keyboard, and it appears to be in two different languages
the text message is being displayed on an iphone's keyboard, and it appears to be in two different languages
an email address is displayed on the phone
an email address is displayed on the phone
an iphone screen showing the settings for different types of text and numbers, including keypads
an iphone screen showing the settings for different types of text and numbers, including keypads
the login screen for adobe id
the login screen for adobe id
jQuery Password Strength Checker With Bootstrap | Password Validation
jQuery Password Strength Checker With Bootstrap | Password Validation
Password Show or Hide Toggle using HTML CSS & JavaScript
Password Show or Hide Toggle using HTML CSS & JavaScript
Password Login Form, Dovetail Login Password, Constant Contact Login Password, Facebook Login Screen, Wifi Login & Password, Facebook Login Page, Password Login Page Screenshot, Gmail Login Password, Facebook Log In
Password Login Form, Dovetail Login Password, Constant Contact Login Password, Facebook Login Screen, Wifi Login & Password, Facebook Login Page, Password Login Page Screenshot, Gmail Login Password, Facebook Log In
Invest Forgot Password | Free Webflow Component
Invest Forgot Password | Free Webflow Component
an info sheet showing the steps in how to use facebook's new accounts
an info sheet showing the steps in how to use facebook's new accounts
the app is showing an image of a man in a tie
the app is showing an image of a man in a tie
an iphone screen with the text'apple pass maly 4291
an iphone screen with the text'apple pass maly 4291
a screen shot of the change password button
a screen shot of the change password button
How we increased our users’ passwords strength by 26%
How we increased our users’ passwords strength by 26%
an iphone screen with two texts on it and the texting section highlighted in the bottom right corner
an iphone screen with two texts on it and the texting section highlighted in the bottom right corner
My Friends Still Use “123456” Passwords—Here’s How I Finally Got Them to Stop
My Friends Still Use “123456” Passwords—Here’s How I Finally Got Them to Stop
the adobe photoshop cc sign up screen
the adobe photoshop cc sign up screen
the login screen shows that there is a new password must be different from the current password
the login screen shows that there is a new password must be different from the current password
Responsive Login Form with Toggle Password Visibility (HTML CSS JavaScript)
Responsive Login Form with Toggle Password Visibility (HTML CSS JavaScript)
VanillaJS : Show/hide password input
VanillaJS : Show/hide password input
Kraken iOS Password input | Mobbin — UI & UX design inspiration for mobile & web apps
Kraken iOS Password input | Mobbin — UI & UX design inspiration for mobile & web apps

Apply Bootstrap's utility classes to style the toggle label and checkbox. For example, you can make the label text color change on hover and add some padding to the input group append element:

```html

```

With these utility classes, the toggle label will have a subtle hover effect, and the input group append element will have some padding on the left.

Custom CSS Styling

For more advanced styling, you can use custom CSS to target specific elements. For instance, you can change the checkbox's appearance and add some transitions for a smoother user experience:

```css #show-password { display: none; } #show-password + label { position: relative; padding-left: 30px; cursor: pointer; } #show-password + label:before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 50%; background-color: #ddd; transition: background-color 0.3s ease; } #show-password:checked + label:before { background-color: #007bff; } #show-password:checked + label { color: #007bff; } ```

With this custom CSS, the checkbox will be hidden, and a pseudo-element will be used to create a custom checkbox appearance. When the checkbox is checked, the pseudo-element's background color and the label's text color will change.

Incorporating a password show/hide toggle in your Bootstrap forms not only enhances user experience but also demonstrates your commitment to security and attention to detail. By following the guidelines outlined above, you can create an intuitive and visually appealing password toggle that integrates seamlessly with your Bootstrap design.