How to change the color of the reveal password button in an HTML <input type="password"> element using CSS

Viewed 1893

The password field in some browsers (Edge anyways) has a little eye icon in the corner as you type in a password field allowing the user to view the password as they type it in. However it defaults to black and I would like to change that so it can be seen on a black background.

::-ms-reveal { color: white; } has no effect.

Is there a way to target this element, either a hack or officially?

1 Answers

The eye icon is implemented as a background image. You can change the background color with the background-color property but to change the foreground color you would need to create your own image and replace it with the background-image property.

Edit: while perusing other questions, I stumbled on the filter css property which solves your problem quite nicely.

input {
  color: white;
  background-color: black;
}
::-ms-reveal {
  filter: invert(100%);
}
Related