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:
- Inline: Styles applied to a single component instance.
- Component: Styles applied to components of a specific type.
- 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 between multiple components.
Hello
World
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.
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