How to approach styling with Scale UI Radix.
Scale UI Radix does not come with a built-in styling system. There’s no css
or sx
prop, and it does not use any styling libraries internally. Under the hood, it’s built with vanilla CSS.
There’s no overhead when it comes to picking a styling technology for your app, but in Scale we suggest to use Tailwind CSS for its utility-first approach and ergonomics.
The components in Scale UI Radix are relatively closed, they come with a set of styles that aren’t always easily overridden. They are customizable within what’s allowed by their props and the theme configuration. We also include semantic colors accent
, neutral
, error
, info
, warning
and success
along with all the colors supported by Radix Themes, you can see more in the color section.
However, you also get access to the same CSS variables that power the Scale UI Radix components, just have in mind that changes to the token system are treated as breaking.
For more information on specific tokens, refer to the corresponding guides in the Theme section or ask in the #scaleui-radix-design channel in Slack.
Beyond simple style overrides, we recommend using the components as-is, or request new features or components so they can be included in the library.
Most components do have className
and style
props, but if you find yourself needing to override a lot of styles, it’s a good sign that you should either:
Out of the box, portalled Radix Themes components can be nested and stacked in any order without conflicts. For example, you can open a popover that opens a dialog, which in turn opens another popover. They all stack on top of each other in the order they were opened:
When building your own components, use the following rules to avoid z-index conflicts:
z-index
values other than auto
, 0
, or -1
in rare cases.Your main content and portalled content are separated by the stacking context that the styles of the root <Theme>
component create. This allows you to stack portalled content on top of the main content without worrying about z-indices.
As of Next.js 13.0 to 14.1, the import order of CSS files in app/**/layout.tsx
is not guaranteed, so Radix Themes may overwrite your own styles even when written correctly:
This Next.js issue may come and go sporadically, or happen only in development or production.
As a workaround, you can merge all the CSS into a single file first via postcss-import and import just that into your layout. Alternatively, importing the styles directly in page.tsx
files also works.
When you render a custom portal in a Radix Themes project, it will naturally appear outside of the root <Theme>
component, which means it won’t have access to most of the theme tokens and styles. To fix that, wrap the portal content with another <Theme>
:
Components like Dialog and Popover in Radix Themes already handle this for you, so this is only necessary when creating your own portalled components.