
Customize the Password Hide/Reveal Button in Microsoft Edge
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:

::: Customize the password reveal button (docs.microsoft.com/en-us/microsoft-edge)
The
passwordinput 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. If youâre visiting a site using a light theme, the function will return the first image-set. In Dark Mode, itâll yield the second image-set.
This function first landed in Chromium in 2019 as -internal-light-dark-color(). Later on it got renamed (chromium/chromium) to its current form.
Unfortunately this handy -internal-light-dark() function is not available in 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;
}
}