demo.rs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. // Customize the webview
  7. |builder| {
  8. builder
  9. .title("Test Dioxus App")
  10. .size(320, 480)
  11. .resizable(true)
  12. .debug(true)
  13. },
  14. // Props
  15. (),
  16. // Draw the root component
  17. |ctx, _props| {
  18. ctx.view(html! {
  19. <div>
  20. <div class="flex items-center justify-center flex-col">
  21. <div class="flex items-center justify-center">
  22. <div class="flex flex-col bg-white rounded p-4 w-full max-w-xs">
  23. // Title
  24. <div class="font-bold text-xl"> "Jon's awesome site!!11" </div>
  25. // Subtext / description
  26. <div class="text-sm text-gray-500"> "He worked so hard on it :)" </div>
  27. <div class="flex flex-row items-center justify-center mt-6">
  28. // Main number
  29. <div class="font-medium text-6xl">
  30. "1337"
  31. </div>
  32. </div>
  33. // Try another
  34. <div class="flex flex-row justify-between mt-6">
  35. <a href="http://localhost:8080/fib/{}" class="underline">
  36. "Legit made my own React"
  37. </a>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. })
  44. },
  45. ).expect("Webview finished");
  46. }