Hover:bg-custom-color not generated if not used in v4 #16820
-
Hi, I'm upgrading to Tailwind 4 and I can't seem to fix this issue. Let's say its index.css looks something like this : @import 'tailwindcss';
@theme static {
--color-used-color: #123456;
--color-unused-color: #456789;
} Let's say the library also exposes this Button component: export const Button = () => {
return <button className="hover:bg-used-color">Button</button>
} When I build my library, I notice that In my front-end application, I import the build css from my library: @import 'tailwindcss';
@import '@library/library/dist/esm/index.css'; As expected, I can use hover:bg-used-color but not hover:bg-unused-color. Bonus question: I do not have suggestions anymore with VSCode plugin Tailwind CSS IntelliSense for my theme variables, even for bg-used-color. Do you know why ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You could add a comment in the library code for export const Button = () => {
/* hover:bg-unused-color */
return <button className="hover:bg-used-color">Button</button>
} This isn't any special syntax. Rather, Tailwind scans files as strings so it will naturally pick up |
Beta Was this translation helpful? Give feedback.
I found the issue: In the front-end application I imported the built CSS from the library instead of the actual CSS source file.
Replacing @import '@library/library/dist/esm/index.css' by '@library/library/src/index.css' did the trick.
@wongjn & @adamwathan Thank you for your answering my question/issue.
Edit: Turns out I need to import both files (source + built CSS)