demo.rs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. Example,
  18. )
  19. .expect("Webview finished");
  20. }
  21. static Example: FC<()> = |ctx, _props| {
  22. ctx.view(html! {
  23. <div>
  24. <div class="flex items-center justify-center flex-col">
  25. <div class="flex items-center justify-center">
  26. <div class="flex flex-col bg-white rounded p-4 w-full max-w-xs">
  27. // Title
  28. <div class="font-bold text-xl"> "Jon's awesome site!!11" </div>
  29. // Subtext / description
  30. <div class="text-sm text-gray-500"> "He worked so hard on it :)" </div>
  31. <div class="flex flex-row items-center justify-center mt-6">
  32. // Main number
  33. <div class="font-medium text-6xl">
  34. "1337"
  35. </div>
  36. </div>
  37. // Try another
  38. <div class="flex flex-row justify-between mt-6">
  39. <a href="http://localhost:8080/fib/{}" class="underline">
  40. "Legit made my own React"
  41. </a>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. })
  48. };