global_css.rs 799 B

12345678910111213141516171819202122232425262728293031
  1. //! Examples: CSS
  2. //! -------------
  3. //!
  4. //! Originally taken from:
  5. //! - https://www.w3schools.com/html/tryit.asp?filename=tryhtml_css_internal
  6. //!
  7. //! Include global styles in your app!
  8. //!
  9. //! You can simply drop in a "style" tag and set the inner contents to your stylesheet.
  10. //! It's slightly more manual than React, but is less magical.
  11. //!
  12. //! A coming update with the assets system will make it possible to include global css from child components.
  13. use dioxus::prelude::*;
  14. fn main() {}
  15. const STYLE: &str = r#"
  16. body {background-color: powderblue;}
  17. h1 {color: blue;}
  18. p {color: red;}
  19. "#;
  20. const Example: FC<()> = |cx| {
  21. cx.render(rsx! {
  22. head { style { "{STYLE}" } }
  23. body {
  24. h1 {"This is a heading"}
  25. p {"This is a paragraph"}
  26. }
  27. })
  28. };