1
0

custom_html.rs 920 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. LaunchBuilder::new()
  7. .cfg(
  8. Config::new().with_custom_head("<style>body { background-color: red; }</style>".into()),
  9. )
  10. .launch(app);
  11. LaunchBuilder::new()
  12. .cfg(
  13. Config::new().with_custom_index(
  14. r#"
  15. <!DOCTYPE html>
  16. <html>
  17. <head>
  18. <title>Dioxus app</title>
  19. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  20. <style>body { background-color: blue; }</style>
  21. </head>
  22. <body>
  23. <div id="main"></div>
  24. </body>
  25. </html>
  26. "#
  27. .into(),
  28. ),
  29. )
  30. .launch(app);
  31. }
  32. fn app() -> Element {
  33. rsx! {
  34. div { h1 { "hello world!" } }
  35. }
  36. }