dioxus/examples/core_reference/inline_styles.rs

30 lines
818 B
Rust
Raw Normal View History

2021-07-16 20:11:25 +00:00
//! Example: Inline Styles
//! ----------------------
//!
//! This example shows how to use inline styles in Dioxus components.
//!
2021-10-24 17:30:36 +00:00
//! Inline styles function very similarly to regular attributes, just grouped together in "style".
2021-07-16 20:11:25 +00:00
//!
//! Inline styles in Dioxus are more performant than React since we're able to cache attributes and compare by pointers.
//! However, it's still not as performant as cascaded styles. Use with care.
2021-07-02 05:30:52 +00:00
use dioxus::prelude::*;
pub fn Example(cx: Scope) -> Element {
2021-07-02 05:30:52 +00:00
cx.render(rsx! {
2021-07-16 20:11:25 +00:00
head {
2022-01-03 18:26:15 +00:00
background_color: "powderblue"
2021-07-16 20:11:25 +00:00
}
body {
2022-01-03 18:26:15 +00:00
h1 {
color: "blue",
2021-07-16 20:11:25 +00:00
"This is a heading"
}
2022-01-03 18:26:15 +00:00
p {
color: "red",
2021-07-16 20:11:25 +00:00
"This is a paragraph"
}
}
})
}