snake_case
.style = {
"font_family": "Comic Sans MS",
"font_size": "16px",
}
app = rx.App(style=style)
accent_color = "#f81ce5"
style = {
"::selection": {
"background_color": accent_color,
},
".some-css-class": {
"text_decoration": "underline",
},
"#special-input": {"width": "20vw"},
rx.Text: {
"font_family": styles.SANS,
},
rx.Divider: {
"margin_bottom": "1em",
"margin_top": "0.5em",
},
rx.Heading: {
"font_weight": "500",
},
rx.Code: {
"color": accent_color,
},
}
app = rx.App(style=style)
snake_case
identifiers into camelCase
format when applying styles. To ensure consistency, it is recommended to use the dash character or camelCase identifiers in your own class names and IDs. To style third-party libraries relying on underscore class names, an external stylesheet should be used. See custom stylesheets for how to reference external CSS files.Hello World
rx.text(
"Hello World",
background_image="linear-gradient(271.68deg, #EE756A 0.75%, #756AEE 88.52%)",
background_clip="text",
font_weight="bold",
font_size="2em",
)
rx.box(
rx.hstack(
rx.button("Default Button"),
rx.button("Red Button", color="red"),
),
color="blue",
)
tailwind
argument of your rxconfig.py
:import reflex as rx
class AppConfig(rx.Config):
pass
config = AppConfig(
app_name="app",
db_url="sqlite:///reflex.db",
env=rx.Env.DEV,
tailwind={},
)
require()
:config = AppConfig(
app_name="app",
db_url="sqlite:///reflex.db",
env=rx.Env.DEV,
tailwind={
"theme": {
"extend": {},
},
"plugins": ["@tailwindcss/typography"],
},
)
class_name
prop: rx.box(
"Hello World",
class_name="text-4xl text-center text-blue-500",
)
tailwind
config to None
. This can be useful if you need to temporarily turn off Tailwind for your project: config = rx.Config(app_name="app", tailwind=None)
Hover Me
rx.box(
rx.text("Hover Me", _hover={"color": "red"}),
)
style
prop. This is useful for reusing styles betweeen multiple components.Hello
World
text_style = {
"color": "green",
"font_family": "Comic Sans MS",
"font_size": "1.2em",
"font_weight": "bold",
"box_shadow": "rgba(240, 46, 170, 0.4) 5px 5px, rgba(240, 46, 170, 0.3) 10px 10px",
}
rx.vstack(
rx.text("Hello", style=text_style),
rx.text("World", style=text_style),
)
style
prop to combine styles.style1 = {
"color": "green",
"font_family": "Comic Sans MS",
"border_radius": "10px",
"background_color": "rgb(107,99,246)",
}
style2 = {
"color": "white",
"border": "5px solid #EE756A",
"padding": "10px",
}
rx.box(
"Multiple Styles",
style=[style1, style2],
)