demo.rs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //! An example where the dioxus vdom is running in a native thread, interacting with webview
  2. //! Content is passed from the native thread into the webview
  3. use dioxus_core::prelude::*;
  4. fn main() {
  5. dioxus_webview::launch(
  6. |builder| {
  7. builder
  8. .title("Test Dioxus App")
  9. .size(320, 480)
  10. .resizable(false)
  11. .debug(true)
  12. },
  13. (),
  14. Example,
  15. )
  16. .expect("Webview finished");
  17. }
  18. static Example: FC<()> = |ctx, _props| {
  19. ctx.render(rsx! {
  20. div {
  21. class: "flex items-center justify-center flex-col"
  22. div {
  23. class: "flex items-center justify-center"
  24. div {
  25. class: "flex flex-col bg-white rounded p-4 w-full max-w-xs"
  26. div { class: "font-bold text-xl", "Example desktop app" }
  27. div { class: "text-sm text-gray-500", "This is running natively" }
  28. div {
  29. class: "flex flex-row items-center justify-center mt-6"
  30. div { class: "font-medium text-6xl", "100%" }
  31. }
  32. div {
  33. class: "flex flex-row justify-between mt-6"
  34. a {
  35. href: "https://www.dioxuslabs.com"
  36. class: "underline"
  37. "Made with dioxus"
  38. }
  39. }
  40. }
  41. }
  42. }
  43. })
  44. };