pub fn Style(props: StyleProps) -> Element
Expand description
Render a style
or link
tag into the head of the page.
If present, the children of the style component must be a single static or formatted string. If there are more children or the children contain components, conditionals, loops, or fragments, the style will not be added.
ยงExample
fn RedBackground() -> Element {
rsx! {
// You can use the style component to render a style tag into the head of the page
// This style tag will set the background color of the page to red
document::Style {
r#"
body {{
background-color: red;
}}
"#
}
// You could also use a style with a href to load a stylesheet asset
document::Style {
href: asset!("/assets/style.css")
}
}
}
Any updates to the props after the first render will not be reflected in the head.