Radix UI cannot be overridden with TailwindCSS v4 #763
Answered
by
rozsazoltan
rozsazoltan
asked this question in
Q&A
-
|
The documentation provides a guide for TailwindCSS v3. However, in v4 you need to rely heavily on CSS layers. How can I import Radix so that it's not unlayered and doesn't end up stronger than TailwindCSS v4 utilities? |
Beta Was this translation helpful? Give feedback.
Answered by
rozsazoltan
Nov 2, 2025
Replies: 1 comment 1 reply
-
|
Place the Radix @import 'tailwindcss';
@import '@radix-ui/themes/styles.css' layer(components);Place your own default styles in the @import 'tailwindcss';
@import '@radix-ui/themes/styles.css' layer(components);
@layer base {
* {
box-sizing: border-box;
padding: 0;
margin: 0;
/* override default font-family, but it will be weaker than all Radix UI styles, which is not a problem */
font-family: "Lato", sans-serif;
}
}
@layer components {
* {
/* it will properly override the styling of Radix UI components, but it will be weaker than the TailwindCSS utilities, so for example the font-serif class will remain strong */
font-family: "Lato", sans-serif;
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rozsazoltan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place the Radix
styles.cssin thecomponentslayer bylayer(components).Place your own default styles in the
baseorcomponentslayer (depending on priority): usecomponentsif you want to override Radix's default styles, orbaseif you don't.