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

Styling

Reflex components can be styled using the full power of CSS.

There are three main ways to add style to your app and they take precedence in the following order:

  1. Inline: Styles applied to a single component instance.
  2. Component: Styles applied to components of a specific type.
  3. Global: Styles applied to all components.

Global Styles

You can pass a style dictionary to your app to apply base styles to all components.

For example, you can set the default font family and font size for your app here just once rather than having to set it on every component.

Component Styles

In your style dictionary, you can also specify default styles for specific component types or arbitrary CSS classes and IDs.

Using style dictionaries like this, you can easily create a consistent theme for your app.

Inline Styles

Inline styles apply to a single component instance. They are passed in as regular props to the component.

Hello World

Children components inherit inline styles unless they are overridden by their own inline styles.

Style Prop

Inline styles can also be set with a style prop. This is useful for reusing styles betweeen multiple components.

Hello

World

Multiple Styles

The style dictionaries are applied in the order they are passed in. This means that styles defined later will override styles defined earlier.

Theming

As of Reflex 'v0.4.0', you can now theme your Reflex web apps. To learn more checkout the Theme docs.

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

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

Tailwind

Reflex supports Tailwind CSS out of the box. To enable it, pass in a dictionary for the tailwind argument of your rxconfig.py:

All Tailwind configuration options are supported. Plugins and presets are automatically wrapped in require():

You can use any of the utility classes under the class_name prop:

Hello World

Disabling Tailwind

If you want to disable Tailwind in your configuration, you can do so by setting the tailwind config to None. This can be useful if you need to temporarily turn off Tailwind for your project:

With this configuration, Tailwind will be disabled, and no Tailwind styles will be applied to your application.

Special Styles

We support all of Chakra UI's pseudo styles.

Below is an example of text that changes color when you hover over it.

Hover Me