Reflex Cloud - Fast, secure & scalable hosting. One command to deploy.

Theming

As of Reflex v0.4.0, you can now theme your Reflex applications. The core of our theming system is directly based on the Radix Themes library. This allows you to easily change the theme of your application along with providing a default light and dark theme. Themes cause all the components to have a unified color appearance.

Overview

The Theme component is used to change the theme of the application. The Theme can be set directly in your rx.App.

Here are the props that can be passed to the rx.theme component:

NameTypeDescription
has_backgroundBoolWhether to apply the themes background color to the theme node. Defaults to True.
appearance"inherit" | "light" | "dark"The appearance of the theme. Can be 'light' or 'dark'. Defaults to 'light'.
accent_colorStrThe primary color used for default buttons, typography, backgrounds, etc.
gray_colorStrThe secondary color used for default buttons, typography, backgrounds, etc.
panel_background"solid" | "translucent"Whether panel backgrounds are translucent: "solid" | "translucent" (default).
radius"none" | "small" | "medium" | "large" | "full"The radius of the theme. Can be 'small', 'medium', or 'large'. Defaults to 'medium'.
scaling"90%" | "95%" | "100%" | "105%" | "110%"Scale of all theme items.

Additionally you can modify the theme of your app through using the Theme Panel component which can be found in the Theme Panel docs.

Colors

Color Scheme

On a high-level, component color_scheme inherits from the color specified in the theme. This means that if you change the theme, the color of the component will also change. Available colors can be found here.

You can also specifiy the color_scheme prop.

Shades

Sometime you may want to use a specific shade of a color from the theme. This is recommended vs using a hex color directly as it will automatically change when the theme changes appearance change from light/dark.

To access a specific shade of color from the theme, you can use the rx.color. When switching to light and dark themes, the color will automatically change. Shades can be accessed by using the color name and the shade number. The shade number ranges from 1 to 12. Additionally, they can have their alpha value set by using the True parameter it defaults to False. A full list of colors can be found here.

NameTypeDescription
colorStrThe color to use. Can be any valid accent color or 'accent' to reference the current theme color.
shade1 - 12The shade of the color to use. Defaults to 7.
alphaBoolWhether to use the alpha value of the color. Defaults to False.

Regular Colors

You can also use standard hex, rgb, and rgba colors.

Toggle Appearance

To toggle between the light and dark mode manually, you can use the toggle_color_mode with the desired event trigger of your choice.

Appearance Conditional Rendering

To render a different component depending on whether the app is in light mode or dark mode, you can use the rx.color_mode_cond component. The first component will be rendered if the app is in light mode and the second component will be rendered if the app is in dark mode.

Reflex Logo dark

This can also be applied to props.