Expand description
Modal dialogs — a trigger button that presents a centered modal panel.
Three cooperating types cover the common dialog use-case. Dialog is the
high-level entry point: a Button (or custom trigger) that, on activation,
presents a ModalContainer above a full-viewport dimming ModalScrim.
DialogContent is the convenience body layout — a VStack with an
optional title, supporting text, scrollable body slot, and a footer slot
separated by a Divider.
§When to use
Dialog::new(label).content(|| …)for the common “button opens dialog” pattern.Dialog::new(label).trigger(my_icon_button).content(|| …)to use a custom widget as the trigger instead of the defaultButton.ModalContainer::new(content)directly when you need to present a modal from handler code viactx.present_modal(ModalRequest::…)rather than a persistent trigger.
§Accessibility
ModalContainer is a Role::Dialog node and announces set_modal().
Its accessible name defaults to the DialogContent title (via
Widget::accessible_title_hint) or falls back to the localized
a11y_dialog_name message; pass .title(tr!(…)) to the container for an
explicit override. The trigger button advertises HasPopup::Dialog and
set_expanded tracks whether the modal is currently open.
use teksilo_widgets::dialog::{Dialog, DialogContent};
use teksilo_i18n::lit;
let _d = Dialog::new(lit!("Open settings"))
.content(|| {
DialogContent::new()
.title(lit!("Settings"))
.supporting_text(lit!("Adjust your preferences below."))
});Structs§
- Dialog
- A trigger button that presents a modal dialog when activated.
- Dialog
Content - Convenience body layout for a modal dialog: optional title, supporting text,
scrollable body slot, and a
Divider-separated footer row. - Modal
Container - Rounded panel chrome that wraps a modal dialog’s content widget.
- Modal
Scrim - Full-viewport dimming scrim painted behind a
ModalContainer.