Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A show password as text toggle for Bootstrap forms

License

NotificationsYou must be signed in to change notification settings

coliff/bootstrap-show-password-toggle

LICENSEGitHub Super-LinterGitHub Starsnpm Versionnpm Downloads

Bootstrap Show Password Toggle

A show password as text toggle for Bootstrap forms

  • Native-looking UI
  • Vanilla JavaScript with no dependencies
  • Base64 encoded SVG icons (no external images or fonts required)
  • Graceful fallback for browsers with JavaScript disabled
  • Works with Bootstrap 4 and 5
  • Supports dark mode (Bootstrap 5 only)
  • Only 1KB gzipped

show password toggle

Quick Start

  • Download the latest release
  • Clone the repogit clone https://github.com/coliff/bootstrap-show-password-toggle.git
  • Install withnpmnpm install bootstrap-show-password-toggle
  • Install withyarnyarn add bootstrap-show-password-toggle

Usage

  1. Include theshow-password-toggle.min.css in your CSS

  2. Wrap the password input in aninput-group div as follows:

<divclass="input-group"><inputtype="password"class="form-control rounded"required><buttonid="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>
  1. Load theshow-password-toggle.min.js after the form

I highly recommend adding the attributes:spellcheck="false",autocorrect="off" andautocapitalize="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 addname="current-password" andautocomplete="current-password" to help browsers autocomplete the form.

Demo

Browser Support

Works well with all the browserssupported by Bootstrap

FAQS

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.

Known Issues

  • If the browser autofills the password input then the user-agent will applybackground-image: none !important.
  • The password input requires the use of therequired 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!)

Credits and Thanks

  • MDO and Bootstrap team for theicons
  • Sam Dutton at Google for the idea and initial JavaScript from the 'Sign-in form Best Practices' article
  • BrowserStack for providing the infrastructure that allows us to test in real browsers

About

A show password as text toggle for Bootstrap forms

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp