[v4] Style hierarchy is not properly applied when used with Mantine #15832
-
Hey All I'm currently working on a project that uses Mantine for the component library and Tailwind CSS for styling. In v3 I had no problem writing Tailwind styles and applying them to Mantine components but in v4, it looks like for some reason all of the mantine default styles are taking precedence over the Tailwind styles. I'm not sure what to do to fix this. In my Next.JS application I already import global.css (containing the tailwind directive and custom theme overrides) last. Does anyone have any insight into this problem Here is my postcss.config file
And in root layout.tsx this is the import order for the css styles
Note the mantine style taking precedence over tailwind style from global.css |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
This is caused by the fact that Tailwind utility classes are now in cascade layers, which have lower precedence than rules not in any layer. You can remove them from the cascade layer like so: -@import "tailwindcss";
+@layer theme, base, components, utilities;
+
+@import "tailwindcss/theme.css" layer(theme);
+@import "tailwindcss/preflight.css" layer(base);
+@import "tailwindcss/utilities.css"; |
Beta Was this translation helpful? Give feedback.
-
I think I've been misled by the official docs, can clarify this somewhere, this issue has been bugging me since the beta version of v4 |
Beta Was this translation helpful? Give feedback.
This is caused by the fact that Tailwind utility classes are now in cascade layers, which have lower precedence than rules not in any layer. You can remove them from the cascade layer like so: