Component Library with Tailwind v4 Custom Layers Being Overridden by Project's Tailwind v3 #18657
Unanswered
kowalczyk-mateusz
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
I'm building a component library using Tailwind v4 that needs to be consumed by projects using Tailwind v3.4.17. I've implemented custom CSS layers to prevent conflicts, but the library's component styles are being overridden by the project's utility classes.
Library Setup (Tailwind v4)
Rollup Configuration:
Library CSS (main.css):
Consuming Project Setup (Tailwind v3.4.17)
Tailwind Config:
Project CSS:
Issue
The library's component styles are being overridden by utility classes. In browser dev tools, I can see:


Expected behavior
Library component styles should take precedence over project's utility classes.
Actual behavior:
Project's utility classes are overriding library's component styles due to layer ordering.
Questions
Environment
Library: React 19, Vite 7, Tailwind v4, PostCSS
Project: Next.js 15, React 19, Tailwind v3.4.17
Beta Was this translation helpful? Give feedback.
All reactions