custom_html.rs 844 B

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