custom_html.rs 880 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //! This example shows how to use a custom index.html and custom <HEAD> extensions
  2. //! to add things like stylesheets, scripts, and third-party JS libraries.
  3. use dioxus::prelude::*;
  4. use dioxus_desktop::Config;
  5. fn main() {
  6. dioxus_desktop::launch_cfg(
  7. app,
  8. Config::new().with_custom_head("<style>body { background-color: red; }</style>".into()),
  9. );
  10. dioxus_desktop::launch_cfg(
  11. app,
  12. Config::new().with_custom_index(
  13. r#"
  14. <!DOCTYPE html>
  15. <html>
  16. <head>
  17. <title>Dioxus app</title>
  18. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  19. <style>body { background-color: blue; }</style>
  20. </head>
  21. <body>
  22. <div id="main"></div>
  23. </body>
  24. </html>
  25. "#
  26. .into(),
  27. ),
  28. );
  29. }
  30. fn app() -> Element {
  31. rsx! {
  32. div {
  33. h1 {"hello world!"}
  34. }
  35. }
  36. }