Skip to content

Instantly share code, notes, and snippets.

@evadecker
Last active April 24, 2025 22:03
Show Gist options
  • Save evadecker/b947c476f62bd9dbf6b17f1a4aa1a034 to your computer and use it in GitHub Desktop.
Save evadecker/b947c476f62bd9dbf6b17f1a4aa1a034 to your computer and use it in GitHub Desktop.
Disable browser native autofill styles
.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