Using CSS variables and theme tokens.
Want to build your theme visually? Use buridan/create to preview colors, radius, and fonts, then generate a preset for your project.
We use and recommend CSS variables for theming. This approach provides semantic design tokens such as background, foreground, and primary, which components rely on by default. You can customize the appearance of your application by overriding these tokens in your CSS, without needing to modify component-level classes.
reflex
To use CSS variables for theming, make the following changes to your rxconfig.py file found at the root of your Reflex app.
Import the tailwind plugin TailwindConfig, add it to the plugins=[...] list, define (or remove if unecessary) darkMode or specific plugins, then finally set the theme and extend the colors based on the CSS tokens in your globals.css file in your assets folder.
rxconfig.py
Further extensions are possible, such as fontFamily, borderRadius, and boxShadow by further extending the theme dictionary as such, making sure each var(...) token is defined in a CSS file.
rxconfig.py
Make sure to pull your CSS files where your tokens are defined in your rx.App instance.
rx.App
Tailwind maps these tokens into utilities like bg-background, text-foreground, border-border, and rounded-radius. Dark mode works by overriding the same tokens inside a .dark selector.
These tokens live in your CSS file under :root and .dark.
To add a new token, define it under :root and .dark, then expose it to Tailwind by appending rxconfig.py.
assets/globals.css
You can now use bg-warning and text-warning-foreground in your components.
reflex
The following is the full default neutral theme scaffold. Copy it into your global CSS file and adjust the tokens as needed. This scaffold also corresponds to preset b0 in buridan/create.
assets/globals.css