Components / Dialog
Dialog
Modal window over a dimmed backdrop.
Example
The component itself, running in WebAssembly, beside its code in a playground. Try it.
Code
use ravenrs::prelude::*;
fn dialog() -> impl View {
let open = State::new(false);
let (show, cancel, confirm) = (open.clone(), open.clone(), open.clone());
VStack::new((
Button::new("Delete project").style(ButtonStyle::Danger).on_click(move || show.set(true)),
Dialog::new(open.binding(), "Delete the project?")
.description("This cannot be undone.")
.action(Button::new("Cancel").style(ButtonStyle::Secondary).on_click(move || cancel.set(false)))
.action(Button::new("Delete").style(ButtonStyle::Danger).on_click(move || confirm.set(false)))
// A stray click outside must not close this one.
.close_on_backdrop(false),
))
}