[V4][WordPress] Common style rules overrides Tailwind layer rules #16934
-
Hello Tailwind community! TL;DR: The actual question is at the end of the message. I'm creating an app to be displayed in WordPress admin view. In WordPress admin views, WP will load it's own default admin styles. These styles most often overrides styles I try to set with Tailwind. Let's take an H2 heading as an example. I create an heading element with Tailwind classes. I try to remove default heading margins set by WordPress admin styles with the
Here is the WordPress admin default stylings for headings (notice the margin rule):
Now my I'm aware that when importing Tailwind in CSS file, you can import it with the
But this will - as you know - generate the Stack that I'm using: WordPress (admin view) + React 19.0 + Vite 6.1 + Tailwind 4.0.6. So the question is: Is there a way to make Tailwind classes as a regular classes (like it was in Tailwind 3.0) instead of CSS layers? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
You could consider unwrapping the utility classes from being in a CSS cascade layer like: -@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.
-
Oh man, I have been debugging for so long before I found out that this was the problem... 😅 Unfortunately, the suggested solution doesn't work for me. I am trying to set a custom font-family like this:
That still adds I am having more luck including the body styles outside of a
But there are a lot more WordPress defaults that I would like to overwrite, like line height, link colors, margins, etc... Moving those styles outside of a Any other idea's how to approach this? |
Beta Was this translation helpful? Give feedback.
You could consider unwrapping the utility classes from being in a CSS cascade layer like: