custom_html.rs 838 B

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