Last active
April 24, 2025 22:03
-
-
Save evadecker/b947c476f62bd9dbf6b17f1a4aa1a034 to your computer and use it in GitHub Desktop.
Disable browser native autofill styles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.disable-autofill:-webkit-autofill, | |
.disable-autofill:autofill { | |
/* Browsers apply !important styles to the background color and text color of autofilled fields, | |
making them impossible to override. Instead, we can set an extremely slow background transition | |
to avoid displaying native styles. This requires setting your preferred styles on a wrapper | |
element using the :autofill pseudo selector. */ | |
transition-property: background-color, color; | |
transition-delay: 0s; | |
transition-duration: 2147483647s; | |
transition-timing-function: linear; | |
background-color: transparent !important; | |
-webkit-text-fill-color: inherit; | |
} | |
/* | |
Sources: | |
https://developer.mozilla.org/en-US/docs/Web/CSS/:autofill | |
https://css-tricks.com/snippets/css/change-autocomplete-styles-webkit-browsers/ | |
https://stackoverflow.com/questions/37861312/what-is-the-maximum-value-of-a-css-transitions-duration | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment