Tailwind autofill: prefix on form inputs not working #8679
Replies: 14 comments 22 replies
-
having the same issue here, I manage to change the input background color by this, but no success in changing the font size (the autofilled font size is smaller than after it is filled) |
Beta Was this translation helpful? Give feedback.
-
Same issue here... |
Beta Was this translation helpful? Give feedback.
-
Facing this issue On |
Beta Was this translation helpful? Give feedback.
-
I made it work with Autoprefixer as described in Tailwind official docs. The idea is to install
Add to module.exports = {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
]
} Then, it will add rules like To change the autofill background color, you actually need to set the
That will set an inset box shadow with yellow color on your input field when autofilled. |
Beta Was this translation helpful? Give feedback.
-
try add "autofill:transition-colors autofill:duration-[5000000ms]" |
Beta Was this translation helpful? Give feedback.
-
In addition to @AydosJs 's answer I also added :enable in order to keep the style after filling the field (the change of the color it's only because of my personal use case):
|
Beta Was this translation helpful? Give feedback.
-
I have same issue on v3.2.4 and Chrome 109.0.5414.119, and |
Beta Was this translation helpful? Give feedback.
-
Same issue autofill:!bg-neutral-800 not work. I must install npm install -D autoprefixer and then use: autofill:shadow-[inset_0_0_0px_1000px_rgb(255,255,0)] |
Beta Was this translation helpful? Give feedback.
-
Still an issue |
Beta Was this translation helpful? Give feedback.
-
autofill:shadow-[inset_0_0_0px_1000px_rgba(var(--background))] for theme color |
Beta Was this translation helpful? Give feedback.
-
I'm struggling in changing color on autofill. I added this to the input element class |
Beta Was this translation helpful? Give feedback.
-
Just circling back on this. The simplest way to apply autofill styling is to add the following in your @tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
.autofill-text:-webkit-autofill {
-webkit-text-fill-color: white;
}
.text-input {
@apply autofill-text; /* set text colour (white) */
@apply autofill:shadow-[inset_0_0_0px_1000px_#000]; /* set 'background' colour (black)*/
@apply autofill:text-2xl; /* set font size */
}
} and then use This is working fine as of tailwind |
Beta Was this translation helpful? Give feedback.
-
I just found issue about dark mode, the input background change to dark. [data-dark-mode-or-maybe-class-onbody] :-webkit-autofill,
[data-dark-mode-or-maybe-class-onbody] :-webkit-autofill:hover,
[data-dark-mode-or-maybe-class-onbody] :-webkit-autofill:focus {
color-scheme: dark;
} |
Beta Was this translation helpful? Give feedback.
-
Tailwind CSS Autofill and Scrollbar Styling with ShadCN and Dark/Light Mode the solution:
Root Variables for Light Mode: Dark Mode Variables: Base Layer Styles: Autofill Input Styling: Custom Scrollbar:
This setup ensures that your autofill inputs and scrollbars remain consistent with your theme, whether in light or dark mode. The use of CSS variables and the @apply directive from Tailwind CSS makes the styles easy to manage and update. If you have any questions or improvements, feel free to comment below! Happy coding! 🎨✨ |
Beta Was this translation helpful? Give feedback.
-
Hello there ! 👋
<input type="password" name="password" id="password" placeholder="name@example.com" class="leading-tight text-sm font-normal flex items-center p-0 dark:text-gray-400 placeholder:dark:text-gray-400 bg-transparent border-0 focus:ring-0 autofill:bg-transparent">
I tried to edit the autofill background on form input because it becomes white even when using a dark theme. But it seems that the autofill: prefix just don't work and I can't figure why... Can someone help with that ?
https://tailwindcss.com/docs/hover-focus-and-other-states#autofill
Beta Was this translation helpful? Give feedback.
All reactions