A show password as text toggle for Bootstrap forms
git clone https://github.com/coliff/bootstrap-show-password-toggle.git
npm install bootstrap-show-password-toggle
yarn add bootstrap-show-password-toggle
Include the show-password-toggle.min.css
in your CSS
Wrap the password input in an input-group
div as follows:
<div class="input-group">
<input type="password" class="form-control rounded" required>
<button id="toggle-password" type="button" class="d-none"
aria-label="Show password as plain text. Warning: this will display your password on the screen.">
</button>
</div>
show-password-toggle.min.js
after the formI highly recommend adding the attributes: spellcheck="false"
, autocorrect="off"
and autocapitalize="off"
to the password input so that when the password is displayed in plain text the input is not auto-corrected, capitalized or spellchecked (to avoid red squiggly line underneath).
You should also add name="current-password"
and autocomplete="current-password"
to help browsers autocomplete the form.
Works well with all the browsers supported by Bootstrap
Q. Can I change the show password icon?
A. Yes you can change the icon displayed by replacing the .input-password[type="password"]
Base64 encoded background image. SVG is recommended.
background-image: none !important
.required
attribute. This is so the background-image is not displayed when the input is empty. (It’d be great if browsers supported the :blank pseudo-selector!)