global_css.rs 791 B

123456789101112131415161718192021222324252627282930
  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. const STYLE: &str = r#"
  15. body {background-color: powderblue;}
  16. h1 {color: blue;}
  17. p {color: red;}
  18. "#;
  19. pub static Example: FC<()> = |cx| {
  20. cx.render(rsx! {
  21. head { style { "{STYLE}" } }
  22. body {
  23. h1 {"This is a heading"}
  24. p {"This is a paragraph"}
  25. }
  26. })
  27. };