dioxus/examples/core_reference/inline_styles.rs

30 lines
818 B
Rust
Raw Normal View History

2021-07-16 16:11:25 -04:00
//! Example: Inline Styles
//! ----------------------
//!
//! This example shows how to use inline styles in Dioxus components.
//!
2021-10-24 19:30:36 +02:00
//! Inline styles function very similarly to regular attributes, just grouped together in "style".
2021-07-16 16:11:25 -04: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 01:30:52 -04:00
use dioxus::prelude::*;
pub fn Example(cx: Scope) -> Element {
2021-07-02 01:30:52 -04:00
cx.render(rsx! {
2021-07-16 16:11:25 -04:00
head {
2022-01-03 13:26:15 -05:00
background_color: "powderblue"
2021-07-16 16:11:25 -04:00
}
body {
2022-01-03 13:26:15 -05:00
h1 {
color: "blue",
2021-07-16 16:11:25 -04:00
"This is a heading"
}
2022-01-03 13:26:15 -05:00
p {
color: "red",
2021-07-16 16:11:25 -04:00
"This is a paragraph"
}
}
})
}