dioxus/examples/webview.rs

30 lines
947 B
Rust
Raw Normal View History

2021-01-22 15:50:16 -05:00
//! Example: Webview Renderer
//!
//! This example shows how to use the dioxus_webview crate to build a basic desktop application.
//!
//! Under the hood, the dioxus_webview crate bridges a native Dioxus VirtualDom with a custom prebuit application running
//! in the webview runtime. Custom handlers are provided for the webview instance to consume patches and emit user events
//! into the native VDom instance.
2021-01-21 11:10:31 -05:00
use dioxus::prelude::*;
fn main() {
2021-01-22 15:50:16 -05:00
let app = dioxus_webview::new(|ctx| {
2021-01-21 11:10:31 -05:00
let (count, set_count) = use_state(ctx, || 0);
2021-01-22 15:50:16 -05:00
2021-01-21 11:10:31 -05:00
html! {
2021-01-22 15:50:16 -05:00
<div>
<h1> "Dioxus Desktop Demo" </h1>
<p> "Count is {count}"</p>
<p> "Count is {count}"</p>
<p> "Data is {data}"</p>
<button onclick=|_| set_count(count + 1) >
"Click to increment"
</button>
2021-01-21 11:10:31 -05:00
</div>
}
});
app.launch(());
}