A centered window over a dimmed page, closed by its × button, Escape or an outside click.
use gpui::{div, prelude::*, Context, Window};
use crate::theme::ActiveTheme;
use crate::ui::button::{Button, ButtonVariant};
use crate::ui::dialog::Dialog;
#[derive(Default)]
pub struct PublishView {
open: bool,
}
impl Render for PublishView {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let theme = cx.theme();
let row = |label: &'static str, value: &'static str| {
div()
.flex()
.justify_between()
.text_sm()
.child(div().text_color(theme.muted_foreground).child(label))
.child(value)
};
Dialog::new("publish", self.open)
.trigger(Button::new("publish-trigger", "Publish release").variant(ButtonVariant::Outline))
.title("Publish v1.4.0")
.description("The release becomes visible to everyone who installs it.")
.on_open_change(cx.listener(|this, open: &bool, _, cx| {
this.open = *open;
cx.notify();
}))
.child(
div()
.flex()
.flex_col()
.gap_2()
.child(row("Tag", "v1.4.0"))
.child(row("Commit", "6195b1a")),
)
.footer(
div()
.flex()
.gap_2()
.child(
Button::new("publish-cancel", "Cancel")
.variant(ButtonVariant::Outline)
.on_click(cx.listener(|this, _, _, cx| {
this.open = false;
cx.notify();
})),
)
.child(Button::new("publish-confirm", "Publish").on_click(cx.listener(
|this, _, _, cx| {
this.open = false;
cx.notify();
},
))),
)
}
}Installation
Copies src/ui/dialog.rs into your project, along with any components it depends on, and registers the module in src/ui/mod.rs.
Install the theme
Every component reads colors from
crate::theme. Follow the installation guide if you have not added it yet.Copy the source
Paste the code below into
src/ui/dialog.rs.src/ui/dialog.rs use std::{cell::OnceCell, rc::Rc, time::Duration}; use gpui::{ anchored, deferred, div, point, prelude::*, px, AnyElement, App, ElementId, FocusHandle, FontWeight, Pixels, SharedString, Size, Window, }; use crate::theme::ActiveTheme; type OpenChangeHandler = Rc<dyn Fn(&bool, &mut Window, &mut App) + 'static>; /// CSS `cubic-bezier(x1, y1, x2, y2)` at time `t`. fn cubic_bezier(x1: f32, y1: f32, x2: f32, y2: f32, t: f32) -> f32 { let sample = |a: f32, b: f32, s: f32| { let r = 1.0 - s; 3.0 * r * r * s * a + 3.0 * r * s * s * b + s * s * s }; let t = t.clamp(0.0, 1.0); let (mut lo, mut hi, mut s) = (0.0_f32, 1.0_f32, t); for _ in 0..24 { let x = sample(x1, x2, s); if (x - t).abs() < 1e-4 { break; } if x < t { lo = s; } else { hi = s; } s = (lo + hi) / 2.0; } sample(y1, y2, s) } /// CSS `ease`, the default timing of shadcn's `animate-in` / `animate-out`. fn ease(t: f32) -> f32 { cubic_bezier(0.25, 0.1, 0.25, 1.0, t) } /// Tailwind's `ease-in-out`, which shadcn's sheet uses. fn tailwind_ease_in_out(t: f32) -> f32 { cubic_bezier(0.4, 0.0, 0.2, 1.0, t) } /// vaul's drawer curve. fn vaul_ease(t: f32) -> f32 { cubic_bezier(0.32, 0.72, 0.0, 1.0, t) } /// How a [`Modal`]'s panel and scrim animate in and out. #[derive(Clone, Copy)] pub struct ModalTransition { /// How long the panel takes to animate in. pub enter: Duration, /// How long the panel takes to animate out; the modal stays mounted until it has. pub exit: Duration, /// How long the scrim takes to fade in or out. pub scrim: Duration, /// The curve both follow. pub easing: fn(f32) -> f32, } impl ModalTransition { /// shadcn's dialog: `fade-in-0 zoom-in-95` / `fade-out-0 zoom-out-95`, `duration-200`. pub const DIALOG: Self = Self { enter: Duration::from_millis(200), exit: Duration::from_millis(200), scrim: Duration::from_millis(150), easing: ease, }; /// shadcn's sheet: slides from its side, `ease-in-out`, 500ms in and 300ms out. pub const SHEET: Self = Self { enter: Duration::from_millis(500), exit: Duration::from_millis(300), scrim: Duration::from_millis(150), easing: tailwind_ease_in_out, }; /// vaul's drawer: 500ms on `cubic-bezier(0.32, 0.72, 0, 1)` both ways, scrim included. pub const DRAWER: Self = Self { enter: Duration::from_millis(500), exit: Duration::from_millis(500), scrim: Duration::from_millis(500), easing: vaul_ease, }; } /// Time on GPUI's clock since the first call. GPUI doesn't export its `Instant`, so moments are /// kept as offsets from one reading. fn clock(cx: &App) -> Duration { type SinceEpoch = Box<dyn Fn(&App) -> Duration>; thread_local! { static SINCE_EPOCH: OnceCell<SinceEpoch> = const { OnceCell::new() }; } SINCE_EPOCH.with(|cell| { let since = cell.get_or_init(|| { let epoch = cx.background_executor().now(); Box::new(move |cx: &App| cx.background_executor().now().saturating_duration_since(epoch)) }); since(cx) }) } /// One eased 0..1 value heading toward open or closed. An interrupted run continues from /// where it is instead of jumping. #[derive(Clone, Copy, Default)] struct Presence { open: bool, from: f32, since: Duration, } impl Presence { fn value(&self, now: Duration, duration: Duration, easing: fn(f32) -> f32) -> f32 { let target = if self.open { 1.0 } else { 0.0 }; let span = (target - self.from).abs(); let duration = duration.as_secs_f32() * span; if span == 0.0 || duration <= 0.0 { return target; } let t = (now.saturating_sub(self.since).as_secs_f32() / duration).min(1.0); self.from + (target - self.from) * easing(t) } /// Returns the value now and whether it is still moving. fn update( &mut self, open: bool, enter: Duration, exit: Duration, easing: fn(f32) -> f32, cx: &App, ) -> (f32, bool) { let now = clock(cx); let duration = |open| if open { enter } else { exit }; if open != self.open { self.from = self.value(now, duration(self.open), easing); self.open = open; self.since = now; } if cx.reduce_motion() { self.from = if open { 1.0 } else { 0.0 }; } let value = self.value(now, duration(open), easing); (value, value != if open { 1.0 } else { 0.0 }) } } /// Where a [`Modal`] puts its panel inside the window. #[derive(Clone, Copy, Default, PartialEq)] pub enum ModalPlacement { #[default] Center, Top, Bottom, Left, Right, } /// The modal layer shared by dialog, alert dialog, sheet and drawer: a scrim over the whole /// window, a panel that takes keyboard focus, and Escape / outside-click dismissal. /// The parent owns `open`; the layer only asks to close through `on_open_change(false)`. #[derive(IntoElement)] pub struct Modal { id: ElementId, open: bool, trigger: Option<AnyElement>, panel: Option<AnyElement>, placement: ModalPlacement, close_on_outside_click: bool, modal: bool, transition: Option<ModalTransition>, on_open_change: Option<OpenChangeHandler>, } /// The focus handle has to live across frames: Escape only reaches the focused element's path. /// The transitions keep the layer mounted while it animates out, and the panel's measured size /// sets how far an edge panel slides. struct ModalState { focus: FocusHandle, was_open: bool, panel: Presence, scrim: Presence, panel_size: Option<Size<Pixels>>, } impl Modal { pub fn new(id: impl Into<ElementId>, open: bool) -> Self { Self { id: id.into(), open, trigger: None, panel: None, placement: ModalPlacement::default(), close_on_outside_click: true, modal: true, transition: None, on_open_change: None, } } /// Clicking this element asks the parent to open the modal. pub fn trigger(mut self, trigger: impl IntoElement) -> Self { self.trigger = Some(trigger.into_any_element()); self } pub fn panel(mut self, panel: impl IntoElement) -> Self { self.panel = Some(panel.into_any_element()); self } pub fn placement(mut self, placement: ModalPlacement) -> Self { self.placement = placement; self } /// Alert dialogs turn this off so a stray click can't dismiss a required decision. pub fn close_on_outside_click(mut self, close: bool) -> Self { self.close_on_outside_click = close; self } /// `false` drops the scrim so the page behind stays visible and clickable while the panel is /// open. A click outside the panel still closes it unless `close_on_outside_click(false)`. pub fn modal(mut self, modal: bool) -> Self { self.modal = modal; self } /// How the panel animates in and out. Defaults to [`ModalTransition::DIALOG`] for a /// centered panel (fade + zoom) and [`ModalTransition::SHEET`] for one on an edge (slide). /// Keep passing the panel while `open` is false so it can animate out. pub fn transition(mut self, transition: ModalTransition) -> Self { self.transition = Some(transition); self } pub fn on_open_change( mut self, handler: impl Fn(&bool, &mut Window, &mut App) + 'static, ) -> Self { self.on_open_change = Some(Rc::new(handler)); self } } impl RenderOnce for Modal { fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement { let open = self.open; let placement = self.placement; let transition = self.transition.unwrap_or(match placement { ModalPlacement::Center => ModalTransition::DIALOG, _ => ModalTransition::SHEET, }); let state = window.use_keyed_state(self.id.clone(), cx, |_, cx| ModalState { focus: cx.focus_handle(), was_open: false, panel: Presence::default(), scrim: Presence::default(), panel_size: None, }); let (focus, just_opened, panel_t, scrim_t, animating, panel_size) = state.update(cx, |state, cx| { let just_opened = open && !state.was_open; state.was_open = open; let (panel_t, panel_moving) = state.panel.update(open, transition.enter, transition.exit, transition.easing, cx); let (scrim_t, scrim_moving) = state.scrim.update(open, transition.scrim, transition.scrim, transition.easing, cx); let animating = panel_moving || scrim_moving; (state.focus.clone(), just_opened, panel_t, scrim_t, animating, state.panel_size) }); if animating && !cx.reduce_motion() { window.request_animation_frame(); } if just_opened { // Deferred content joins the dispatch tree a frame late; Zed's modals wait two frames. let focus = focus.clone(); window.on_next_frame(move |window, _| { window.on_next_frame(move |window, cx| window.focus(&focus, cx)); }); } let on_open_change = self.on_open_change; let trigger = self.trigger.map(|trigger| { let handler = on_open_change.clone(); div() .id("modal-trigger") .when_some(handler, |this, handler| { this.on_click(move |_, window, cx| handler(&true, window, cx)) }) .child(trigger) }); // Still up while animating out, so the docs page keeps its overlay until the end. let showing = open || animating; if showing && self.panel.is_some() { crate::theme::mark_overlay(cx); } let layer = self.panel.filter(|_| showing).map(|panel| { // The layer is sized to the window rather than `size_full`: it renders wherever the // modal sits in the tree, which is usually inside a smaller, padded container. let viewport = window.viewport_size(); let close_outside = on_open_change.clone().filter(|_| self.close_on_outside_click); let escape = on_open_change.clone(); let panel = div() .occlude() .track_focus(&focus) .on_mouse_down_out(move |_, window, cx| { if let Some(close) = &close_outside { close(&false, window, cx); } }) .on_key_down(move |event, window, cx| { if event.keystroke.key == "escape" { if let Some(escape) = &escape { escape(&false, window, cx); } cx.stop_propagation(); } }) .child(panel); // Until the panel has been measured, slide by the whole window: it starts off // screen either way. let size = panel_size.unwrap_or(viewport); let rest = 1.0 - panel_t; let panel = match placement { // GPUI can't scale an element, so zoom-95 is drawn as the travel of the panel's // top edge (2.5% of its height) along with the fade. ModalPlacement::Center => panel .opacity(panel_t.clamp(0.0, 1.0)) .top(size.height * 0.025 * rest), ModalPlacement::Top => panel.top(-size.height * rest), ModalPlacement::Bottom => panel.top(size.height * rest), ModalPlacement::Left => panel.left(-size.width * rest), ModalPlacement::Right => panel.left(size.width * rest), }; let scrim = self.modal.then(|| { div() .id("modal-scrim") .absolute() .inset_0() .occlude() // Black at 50% (shadcn's bg-black/50) dims both themes; a theme color would vanish over a light page. .bg(gpui::black().opacity(0.5)) .opacity(scrim_t.clamp(0.0, 1.0)) }); let measure = state.clone(); let layout = div() .relative() .flex() .w(viewport.width) .h(viewport.height) .on_children_prepainted(move |bounds, _, cx| { // The panel is the last child, after the scrim. let size = bounds.last().map(|bounds| bounds.size); measure.update(cx, |state, _| state.panel_size = size); }); let layout = match placement { ModalPlacement::Center => layout.items_center().justify_center().p_4(), ModalPlacement::Top => layout.flex_col().justify_start(), ModalPlacement::Bottom => layout.flex_col().justify_end(), ModalPlacement::Left => layout.justify_start(), ModalPlacement::Right => layout.justify_end(), }; deferred( anchored() .position(point(px(0.0), px(0.0))) .child(layout.children(scrim).child(panel)), ) .with_priority(2) }); div().id(self.id).children(trigger).children(layer) } } /// The small "×" in a modal's top-right corner. pub fn close_button( id: impl Into<ElementId>, handler: impl Fn(&mut Window, &mut App) + 'static, cx: &App, ) -> impl IntoElement { let theme = cx.theme(); div() .id(id.into()) .absolute() .top(px(12.0)) .right(px(12.0)) .size(px(24.0)) .flex() .items_center() .justify_center() .rounded(px(4.0)) .text_color(theme.foreground) .text_lg() .opacity(0.7) .cursor_pointer() .hover(|style| style.opacity(1.0)) .on_click(move |_, window, cx| handler(window, cx)) .child("×") } /// A centered window over a dimmed page. The parent owns `open`. #[derive(IntoElement)] pub struct Dialog { id: ElementId, open: bool, trigger: Option<AnyElement>, title: Option<SharedString>, description: Option<SharedString>, children: Vec<AnyElement>, footer: Option<AnyElement>, show_close_button: bool, on_open_change: Option<OpenChangeHandler>, } impl Dialog { pub fn new(id: impl Into<ElementId>, open: bool) -> Self { Self { id: id.into(), open, trigger: None, title: None, description: None, children: Vec::new(), footer: None, show_close_button: true, on_open_change: None, } } /// Clicking this element asks the parent to open the dialog. pub fn trigger(mut self, trigger: impl IntoElement) -> Self { self.trigger = Some(trigger.into_any_element()); self } pub fn title(mut self, title: impl Into<SharedString>) -> Self { self.title = Some(title.into()); self } pub fn description(mut self, description: impl Into<SharedString>) -> Self { self.description = Some(description.into()); self } /// Right-aligned actions under the body. pub fn footer(mut self, footer: impl IntoElement) -> Self { self.footer = Some(footer.into_any_element()); self } /// `false` hides the "×" in the top-right corner; the dialog then closes through Escape, an /// outside click, or a button of your own. pub fn show_close_button(mut self, show: bool) -> Self { self.show_close_button = show; self } /// Receives the *next* open value. pub fn on_open_change( mut self, handler: impl Fn(&bool, &mut Window, &mut App) + 'static, ) -> Self { self.on_open_change = Some(Rc::new(handler)); self } } impl ParentElement for Dialog { fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) { self.children.extend(elements); } } impl RenderOnce for Dialog { fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { let theme = cx.theme(); let has_header = self.title.is_some() || self.description.is_some(); let on_open_change = self.on_open_change; let close = on_open_change.clone(); let panel = div() .relative() .flex() .flex_col() .gap_4() .w(px(448.0)) .p_6() .rounded(theme.radius) .border_1() .border_color(theme.border) .bg(theme.background) .text_color(theme.foreground) .shadow_lg() .when(has_header, |this| { this.child( div() .flex() .flex_col() .gap_2() .when(self.show_close_button, |this| this.pr_6()) .when_some(self.title, |this, title| { this.child( div() .text_lg() .font_weight(FontWeight::SEMIBOLD) .line_height(px(20.0)) .child(title), ) }) .when_some(self.description, |this, description| { this.child( div() .text_sm() .text_color(theme.muted_foreground) .child(description), ) }), ) }) .children(self.children) .when_some(self.footer, |this, footer| { this.child(div().flex().justify_end().gap_2().child(footer)) }) .when(self.show_close_button, |this| { this.child(close_button( "dialog-close", move |window, cx| { if let Some(close) = &close { close(&false, window, cx); } }, cx, )) }); Modal::new(self.id, self.open) .when_some(self.trigger, |this, trigger| this.trigger(trigger)) .when_some(on_open_change, |this, handler| { this.on_open_change(move |open, window, cx| handler(open, window, cx)) }) .panel(panel) } }Register the module
// src/ui/mod.rs pub mod dialog;
Usage
use crate::ui::dialog::*;Examples
Custom Close Button
Pass a button of your own in footer and close the dialog from its click handler.
use gpui::{div, prelude::*, px, Context, Window};
use crate::theme::ActiveTheme;
use crate::ui::button::{Button, ButtonVariant};
use crate::ui::dialog::Dialog;
#[derive(Default)]
pub struct DialogCustomClose {
open: bool,
}
impl Render for DialogCustomClose {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let theme = cx.theme();
Dialog::new("dialog-custom-close", self.open)
.trigger(Button::new("dialog-custom-close-trigger", "Share").variant(ButtonVariant::Outline))
.title("Share link")
.description("Anyone who has this link will be able to view this.")
.on_open_change(cx.listener(|this, open: &bool, _, cx| {
this.open = *open;
cx.notify();
}))
.child(
div()
.h(px(36.0))
.px_3()
.flex()
.items_center()
.rounded(theme.radius)
.border_1()
.border_color(theme.input)
.text_sm()
.text_color(theme.muted_foreground)
.child("https://hyuskui.com/docs/installation"),
)
.footer(
Button::new("dialog-custom-close-button", "Close")
.variant(ButtonVariant::Secondary)
.on_click(cx.listener(|this, _, _, cx| {
this.open = false;
cx.notify();
})),
)
}
}No Close Button
show_close_button(false) hides the "×". The dialog still closes on Escape or a click outside.
use gpui::{prelude::*, Context, Window};
use crate::ui::button::{Button, ButtonVariant};
use crate::ui::dialog::Dialog;
#[derive(Default)]
pub struct DialogNoCloseButton {
open: bool,
}
impl Render for DialogNoCloseButton {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
Dialog::new("dialog-no-close", self.open)
.trigger(Button::new("dialog-no-close-trigger", "No Close Button").variant(ButtonVariant::Outline))
.title("No Close Button")
.description(
"This dialog doesn't have a close button in the top-right corner. Press Escape or \
click outside to close it.",
)
.show_close_button(false)
.on_open_change(cx.listener(|this, open: &bool, _, cx| {
this.open = *open;
cx.notify();
}))
}
}Sticky Footer
Put long content in a scroll container with a max height; the footer sits outside it, so the actions stay in view while the content scrolls.
use gpui::{div, prelude::*, px, Context, FontWeight, Window};
use crate::theme::ActiveTheme;
use crate::ui::button::{Button, ButtonVariant};
use crate::ui::dialog::Dialog;
const SECTIONS: [(&str, &str); 6] = [
("Accounts", "You are responsible for keeping your credentials safe and for everything that happens under your account."),
("Acceptable use", "Don't use the service to break the law, send spam, or interfere with other people's use of it."),
("Your content", "You keep ownership of what you upload. You grant us the rights needed to store and display it for you."),
("Billing", "Paid plans renew automatically each month. You can cancel at any time and keep access until the period ends."),
("Termination", "We may suspend accounts that break these terms. You can export your data for 30 days afterwards."),
("Changes", "We'll email you at least two weeks before any change to these terms takes effect."),
];
#[derive(Default)]
pub struct DialogStickyFooter {
open: bool,
}
impl Render for DialogStickyFooter {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let theme = cx.theme();
Dialog::new("dialog-sticky-footer", self.open)
.trigger(Button::new("dialog-sticky-footer-trigger", "Sticky Footer").variant(ButtonVariant::Outline))
.title("Terms of Service")
.description("Please read the terms before you continue.")
.on_open_change(cx.listener(|this, open: &bool, _, cx| {
this.open = *open;
cx.notify();
}))
.child(
div()
.id("dialog-sticky-footer-body")
.max_h(px(240.0))
.overflow_y_scroll()
.flex()
.flex_col()
.gap_4()
.text_sm()
.children(SECTIONS.iter().map(|(heading, body)| {
div()
.flex()
.flex_col()
.gap_1()
.child(div().font_weight(FontWeight::MEDIUM).child(*heading))
.child(div().text_color(theme.muted_foreground).child(*body))
})),
)
.footer(
Button::new("dialog-sticky-footer-close", "Close")
.variant(ButtonVariant::Outline)
.on_click(cx.listener(|this, _, _, cx| {
this.open = false;
cx.notify();
})),
)
}
}Scrollable Content
Long content scrolls inside a container with a max height while the title stays in view.
use gpui::{div, prelude::*, px, Context, FontWeight, Window};
use crate::theme::ActiveTheme;
use crate::ui::button::{Button, ButtonVariant};
use crate::ui::dialog::Dialog;
const RELEASES: [(&str, &str); 8] = [
("v1.8.0", "Adds a hover card, keyboard navigation for menus, and a compact density setting."),
("v1.7.2", "Fixes the input caret jumping when text is pasted into a selection."),
("v1.7.0", "Sheets slide in from any edge. Dialogs animate in with a short fade."),
("v1.6.1", "Tooltips no longer flicker when the pointer crosses the trigger's border."),
("v1.6.0", "New toggle group and button group components."),
("v1.5.0", "Dark theme tokens are tuned for contrast; borders are easier to see."),
("v1.4.0", "Adds popover alignment and window-edge collision handling."),
("v1.3.0", "First release of the command-line installer."),
];
#[derive(Default)]
pub struct DialogScrollableContent {
open: bool,
}
impl Render for DialogScrollableContent {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let theme = cx.theme();
Dialog::new("dialog-scrollable", self.open)
.trigger(Button::new("dialog-scrollable-trigger", "Scrollable Content").variant(ButtonVariant::Outline))
.title("Changelog")
.description("Everything that changed in recent releases.")
.on_open_change(cx.listener(|this, open: &bool, _, cx| {
this.open = *open;
cx.notify();
}))
.child(
div()
.id("dialog-scrollable-body")
.max_h(px(280.0))
.overflow_y_scroll()
.flex()
.flex_col()
.gap_4()
.text_sm()
.children(RELEASES.iter().map(|(version, notes)| {
div()
.flex()
.flex_col()
.gap_1()
.child(div().font_weight(FontWeight::MEDIUM).child(*version))
.child(div().text_color(theme.muted_foreground).child(*notes))
})),
)
}
}API Reference
ModalPlacement
Where a [Modal] puts its panel inside the window.
ModalPlacement::CenterModalPlacement::TopModalPlacement::BottomModalPlacement::LeftModalPlacement::RightModal
The modal layer shared by dialog, alert dialog, sheet and drawer: a scrim over the whole window, a panel that takes keyboard focus, and Escape / outside-click dismissal. The parent owns open; the layer only asks to close through on_open_change(false).
Modal::new(id: impl Into<ElementId>, open: bool) -> Self.trigger(trigger: impl IntoElement)Clicking this element asks the parent to open the modal.
.panel(panel: impl IntoElement).placement(placement: ModalPlacement).close_on_outside_click(close: bool)Alert dialogs turn this off so a stray click can't dismiss a required decision.
.modal(modal: bool)false drops the scrim so the page behind stays visible and clickable while the panel is open. A click outside the panel still closes it unless close_on_outside_click(false).
.transition(transition: ModalTransition)How the panel animates in and out. Defaults to [ModalTransition::DIALOG] for a centered panel (fade + zoom) and [ModalTransition::SHEET] for one on an edge (slide). Keep passing the panel while open is false so it can animate out.
.on_open_change(handler: impl Fn(&bool, &mut Window, &mut App) + 'static)Dialog
A centered window over a dimmed page. The parent owns open.
Dialog::new(id: impl Into<ElementId>, open: bool) -> Self.trigger(trigger: impl IntoElement)Clicking this element asks the parent to open the dialog.
.title(title: impl Into<SharedString>).description(description: impl Into<SharedString>).footer(footer: impl IntoElement)Right-aligned actions under the body.
.show_close_button(show: bool)false hides the "×" in the top-right corner; the dialog then closes through Escape, an outside click, or a button of your own.
.on_open_change(handler: impl Fn(&bool, &mut Window, &mut App) + 'static)Receives the *next* open value.