webview.rs 878 B

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