webview.rs 947 B

1234567891011121314151617181920212223242526272829
  1. //! Example: Webview Renderer
  2. //!
  3. //! This example shows how to use the dioxus_webview crate to build a basic desktop application.
  4. //!
  5. //! Under the hood, the dioxus_webview crate bridges a native Dioxus VirtualDom with a custom prebuit application running
  6. //! in the webview runtime. Custom handlers are provided for the webview instance to consume patches and emit user events
  7. //! into the native VDom instance.
  8. use dioxus::prelude::*;
  9. fn main() {
  10. let app = dioxus_webview::new(|ctx| {
  11. let (count, set_count) = use_state(ctx, || 0);
  12. html! {
  13. <div>
  14. <h1> "Dioxus Desktop Demo" </h1>
  15. <p> "Count is {count}"</p>
  16. <p> "Count is {count}"</p>
  17. <p> "Data is {data}"</p>
  18. <button onclick=|_| set_count(count + 1) >
  19. "Click to increment"
  20. </button>
  21. </div>
  22. }
  23. });
  24. app.launch(());
  25. }