dioxus/examples/multiwindow.rs
2024-02-14 12:33:07 -08:00

28 lines
655 B
Rust

//! Multiwindow example
//!
//! This exmaple shows how to implement a simple multiwindow application using dioxus.
//! This works by spawning a new window when the user clicks a button. We have to build a new virtualdom which has its
//! own context, root elements, etc.
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
}
fn app() -> Element {
let onclick = move |_| {
let dom = VirtualDom::new(popup);
dioxus::desktop::window().new_window(dom, Default::default());
};
rsx! {
button { onclick, "New Window" }
}
}
fn popup() -> Element {
rsx! {
div { "This is a popup window!" }
}
}