Replies: 1 comment 1 reply
-
| bump on this, need this info too if anyone got past this~ | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
  
    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.
-
I am in the process of upgrading a Next.js v14 project (using the App Router) from Tailwind CSS v3 to v4. Our project also uses
styled-componentsfor an internal component library.The Problem
With Tailwind v3, our styles worked as expected, with Tailwind utility classes correctly overriding styles from
styled-components.After upgrading to v4, the CSS load order appears to have changed. Now, styles from
styled-componentsare taking precedence over Tailwind, which breaks parts of our UI. For example, a class that previously worked on a modal no longer applies its styles:I've also noticed a change in how style tags are injected.
<style data-styled="active" data-styled-version="5.3.11"></style>tag theheadand<style data-styled data-styled-version="5.3.11"></style>in thebodyof the rendered HTML.<style data-styled="active" data-styled-version="5.3.11"></style>tag in thehead.What I've Tried
To fix this, I updated my
global.cssfile to use the new v4 syntax. This configuration seems to resolve the precedence issue:This works because importing
tailwindcss/utilities.cssoutside of a@layerblock gives it the highest precedence, forcing it to override thestyled-componentsstyles.My Questions
While this fixes the immediate problem, I'm concerned it's not the correct long-term solution.
utilitieslayer? Will this cause other specificity problems later on?styled-componentsto ensure the correct style injection order in a Next.js App Router environment?Beta Was this translation helpful? Give feedback.
All reactions