Customize the Password Hide/Reveal Button in Microsoft Edge

If you’re using Microsoft Edge, you might have noticed that it sports “Reveal Password” control — a little eye icon — automatically injected on the end side of password inputs: As per Edge Developer Docs: The password input type in Microsoft Edge includes a password reveal control. To make sure that the password is entered …


This content originally appeared on Bram.us and was authored by Bramus!

If you’re using Microsoft Edge, you might have noticed that it sports “Reveal Password” control — a little eye icon — automatically injected on the end side of password inputs:

As per Edge Developer Docs:

The password input type in Microsoft Edge includes a password reveal control. To make sure that the password is entered correctly, a user can click the password reveal button or press Alt+F8, to show the characters in the password field.

A password field with dots hiding the characters entered by a user. The password reveal button appears to the right of the password field. The eye-shaped icon appears next to the dots that hide the password text.

It’s a nice feature I must say, but it’s a bit quirky: it only shows the control as long as the input remains focussed. If you blur the control and later on refocus, you won’t be able to reveal the password, as demonstrated in this video:

When starting from scratch again, i.e. after clearing the password, it’ll work as expected again. I’m pretty sure this is a security feature, to make the stealing of passwords a little harder than simply pressing the password-reveal control.

~

As an author, you can use the non-standardized ::-ms-reveal pseudo class to style the reveal password control:

::-ms-reveal {
  border: 1px solid red;
}

🤔 Curious to know why it’s this specific pseudo-element selector? You can use the DevTools to discover it yourself.

Unfortunately there’s no easy way to only control only the color of the icon used, as it’s an inlined SVG. Here’s how they did it, as seen in the UA Stylesheet that ships with Edge.

::-ms-reveal {
  background-image: -internal-light-dark(
    -webkit-image-set(url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xLjI2IDkuNkE2Ljk3IDYuOTcgMCAwMTggNGMzLjIgMCA2LjA2IDIuMzMgNi43NCA1LjZhLjUuNSAwIDAwLjk4LS4yQTcuOTcgNy45NyAwIDAwOCAzIDcuOTcgNy45NyAwIDAwLjI4IDkuNGEuNS41IDAgMDAuOTguMnoiIGZpbGw9IldpbmRvd1RleHQiLz48cGF0aCBkPSJNOCA2YTMuNSAzLjUgMCAxMDAgNyAzLjUgMy41IDAgMDAwLTd6TTUuNSA5LjVhMi41IDIuNSAwIDExNSAwIDIuNSAyLjUgMCAwMS01IDB6IiBmaWxsPSJXaW5kb3dUZXh0Ii8+DQo8L3N2Zz4=") 1x),
    -webkit-image-set(url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xLjI2IDkuNkE2Ljk3IDYuOTcgMCAwMTggNGMzLjIgMCA2LjA2IDIuMzMgNi43NCA1LjZhLjUuNSAwIDAwLjk4LS4yQTcuOTcgNy45NyAwIDAwOCAzIDcuOTcgNy45NyAwIDAwLjI4IDkuNGEuNS41IDAgMDAuOTguMnoiIGZpbGw9IiNmZmZmZmYiLz48cGF0aCBkPSJNOCA2YTMuNSAzLjUgMCAxMDAgNyAzLjUgMy41IDAgMDAwLTd6TTUuNSA5LjVhMi41IDIuNSAwIDExNSAwIDIuNSAyLjUgMCAwMS01IDB6IiBmaWxsPSIjZmZmZmZmIi8+DQo8L3N2Zz4=") 1x)
  );
}

To change the color, you’ll have to overwrite the entire background-image.

🔥 The -internal-light-dark() function you see there definitely caught my eye. The Microsoft folks use it to ship a light and dark image in one go. If you’re visiting a site using a light theme, it’ll take the first image-set. In Dark Mode, it’ll take the second image-set.

Unfortunately this handy -internal-light-dark() function is not exposed to the Author Origin.

Addiontally, if you’re thinking of using CSS to always show the ::-ms-reveal control using display: block !important; then I’ll have to disappoint you: the control does show it, but it’s not functional.

::-ms-reveal {
  display: block !important; /* Will always show the control but clicking it won't reveal already filled values */
}

~

In his post How to hide Microsoft Edge’s password reveal button, Stefan Judis warns for this automatically provided control: if you’re sporting your own Show/Hide Password logic, it might conflict with Edge’s one. To cater for this, Stefan suggests to hide Edge’s provided toggle:

::-ms-reveal {
  display: none;
}

Alternatively you could opt to hide your own implementation when ::-ms-reveal support is detected:

@supports(selector(::-ms-reveal)) {
  .my_custom_password_toggle {
    display: none;
  }
}

~

🔥 Like what you see? Want to stay in the loop? Here's how:


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2022-01-11T22:27:41+00:00) Customize the Password Hide/Reveal Button in Microsoft Edge. Retrieved from https://www.scien.cx/2022/01/11/customize-the-password-hide-reveal-button-in-microsoft-edge/

MLA
" » Customize the Password Hide/Reveal Button in Microsoft Edge." Bramus! | Sciencx - Tuesday January 11, 2022, https://www.scien.cx/2022/01/11/customize-the-password-hide-reveal-button-in-microsoft-edge/
HARVARD
Bramus! | Sciencx Tuesday January 11, 2022 » Customize the Password Hide/Reveal Button in Microsoft Edge., viewed ,<https://www.scien.cx/2022/01/11/customize-the-password-hide-reveal-button-in-microsoft-edge/>
VANCOUVER
Bramus! | Sciencx - » Customize the Password Hide/Reveal Button in Microsoft Edge. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/11/customize-the-password-hide-reveal-button-in-microsoft-edge/
CHICAGO
" » Customize the Password Hide/Reveal Button in Microsoft Edge." Bramus! | Sciencx - Accessed . https://www.scien.cx/2022/01/11/customize-the-password-hide-reveal-button-in-microsoft-edge/
IEEE
" » Customize the Password Hide/Reveal Button in Microsoft Edge." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2022/01/11/customize-the-password-hide-reveal-button-in-microsoft-edge/. [Accessed: ]
rf:citation
» Customize the Password Hide/Reveal Button in Microsoft Edge | Bramus! | Sciencx | https://www.scien.cx/2022/01/11/customize-the-password-hide-reveal-button-in-microsoft-edge/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.