- Docs
- enzUI framework
- Developers
Dialogs, menus and popovers
Modal dialogs and their presets, stacked dialogs, context menus, menu bars, popovers and how overlays place themselves.
Everything drawn above the page falls into two halves. Dialogs are modal: the page behind them goes inert. Menus, popovers and tooltips are not: they close on an outside press or Escape and leave the page live.
See every widget in the widget catalog.

The modal host
modal_host owns modality: the scrim, background inertness, Escape, dismissal routing, and keeping the dialog drawn until its exit motion settles. It owns nothing about how the dialog looks. modal_surface is the surface dialog content sits on, and capped_dialog_body wraps a dialog with a scrolling body and a pinned action footer.
The presets compose those pieces, so prefer them to building a dialog by hand:
| Preset | Use |
|---|---|
enz_confirm_dialog | "Are you sure?" with an optional checkbox; alert status is explicit, not inferred from a destructive tone |
enz_save_changes_dialog | The three-action "Save changes before closing?" |
enz_form_dialog | A dynamic, validated form; see below |
enz_settings_dialog | Preferences with tabs, a sidebar or stacked pages |
about_dialog::enz_about_dialog | Icon, name, version, developer, links, release notes, credits and legal text, localized |
enz_shortcuts_dialog | Keyboard-shortcut help |
enz_sheet | A sheet with detents, drag and an accessible grabber |
enz_full_screen_overlay | Dimming scrim, centred content and a close button |
Dialog corners follow the theme file's [shape] dialog step, which defaults to window, so a dialog's corners match the window behind it.
Dialogs over dialogs
modal_host::DialogStack<Key> keeps several dialogs as one value in the app state:
open(key, invoker)moves focus into the dialog;open_alert(..)opens one as an alert.- Escape closes only the topmost dialog, and closing one closes those opened over it.
hand_off(from, to)replaces one dialog with the next (Rename handing off to Properties).dismiss(&key, cause)is for the dialog's own Save, Cancel or Close button and returns focus to the invoker, as Escape does;close(&key)is for a dialog whose subject went away.- While an operation the dialog started is running,
set_policy(&key, alert_dismiss_policy())makes Escape and the scrim leave it open. view(page, |key| dialog, Message::Dialog)renders them with every host level kept mounted.
Message::Menu(event) => {
let (chosen, focus) = self.menu.update(&event);
let Some((index, command)) = chosen else {
return focus;
};
let open = match command {
Command::Rename => self.dialogs.open(Dialog::Rename(index), Some(row_id(index))),
Command::Delete => self.dialogs.open_alert(Dialog::Delete(index), Some(row_id(index))),
// ...
};
Task::batch([focus, open])
}
Message::Dialog(event) => self.dialogs.update(event).1,
Message::MoreOptions(index) => self
.dialogs
.hand_off(&Dialog::Rename(index), Dialog::Properties(index)),Forms in a dialog
Build a validated form from a FormModel and present it with enz_form_dialog.
use enzui_core::form::{ChoiceOption, FormField, FormModel};
FormModel::new(vec![
FormField::text("name", "Full name").required(true).placeholder("Ada Lovelace"),
FormField::text("email", "Email")
.required(true)
.validator(email_validator)
.helper("We send the confirmation here."),
FormField::secure("password", "Password").required(true),
FormField::choice("plan", "Plan", vec![
ChoiceOption::new("free", "Free"),
ChoiceOption::new("pro", "Pro"),
])
.unwrap(),
FormField::toggle("newsletter", "Send me the newsletter", false),
])A FormPresenter holds the session. Feed it FormDialogEvents with presenter.update(event, None), which returns an optional FormOutcome (Submitted(submission) or Dismissed(cause)) and a task. Read submitted values by field id: submission.text(&FieldId::new("email")). In the view:
enz_form_dialog("Create an account", presenter.session(), Message::Form)
.description("Name, email and password are required.")
.submit_label("Create")
.presenter(presenter)
.into_host(content)Settings dialog
enz_settings_dialog owns adaptive dialog or sheet presentation, navigation, scrolling pane bodies and modal hosting. Navigation resolves to tabs, a sidebar or stacked pages; one page has no navigation.
use enzui_widgets::settings_dialog::{SettingsPage, enz_settings_dialog};
enz_settings_dialog(open, window_size)
.title("Settings")
.scope_key("app-settings")
.page(SettingsPage::new("general", "General").icon("settings"), general_pane())
.page(SettingsPage::new("privacy", "Privacy").icon("shield"), privacy_pane())
.selected(selected_page)
.on_select(Message::SelectSettingsPage)
.on_done(Message::CloseSettings)
.into_host_with(app_view, Message::SettingsEvent)Store the page id from SelectSettingsPage and feed it back through .selected(..). Mounting the host does not move focus by itself: when opening, capture the invoker id and run modal_host::initial_focus_operation for modal_host::presentation_scope_id("app-settings"). ModalFocusLifecycle bundles the open, traversal and dismissal steps into one state object.
The preset supports several layouts, including a page of preference groups that the preset scrolls, a page that owns its scrolling (SettingsPage::owns_scroll) with a filter above its list, and Save and Revert pinned in the footer.
Context menus
context_menu_host::ContextMenu<Target, Command> is a typed right-click menu kept as one value in the app state. Open it from a row's on_context (or enz_context_target) with ContextMenuItems, mount it once around the view with menu.host(page, Message::Menu), and menu.update(&event) returns the chosen (target, command) and the task that returns focus to the row.
self.menu.open_restoring(
index,
InvocationKind::Pointer(MenuPoint::new(at.x, at.y)),
vec![
ContextMenuItem::command(Command::Rename, tr("rename")).icon("pencil"),
ContextMenuItem::submenu(tr("move-to"), vec![
ContextMenuItem::command(Command::MoveTo("Work"), tr("work")),
ContextMenuItem::command(Command::MoveTo("Home"), tr("home")),
])
.icon("folder-open"),
ContextMenuItem::separator(),
ContextMenuItem::command(Command::Delete, tr("delete"))
.icon("trash-2")
.destructive(true),
],
FocusRestoreTarget::Widget(row_id(index)),
);Menu buttons and the menu bar
enz_menu_button(label, &model, &state, Message::Menu)opens a menu built from anenzui_core::menu_model::MenuModel;apply_event(&mut model, &mut state, &event)returns the chosen entry. Entries areMenuEntryModel::command(..)(with.shortcut("Ctrl+O")),submenu(..)andseparator(..). Right or Enter opens a submenu; Left or Escape closes it.menu_bar::enz_menu_baris a desktop menu bar (File, Edit, View, Help) from aMenuBarModel, with submenus, check and radio items, shortcuts and access keys. F10 opens the first menu and the arrow keys move through menus. See themenu_barexample.enz_kebab_menu_buttonandenz_split_menu_buttonare the⋯and split variants.
Popovers
enz_popover(anchor, content, on_dismiss) attaches a floating panel holding any content to a control. It closes on an outside press or Escape. Move focus in when it opens:
Message::ToggleShare => {
self.share_open = !self.share_open;
if self.share_open {
return iced::advanced::widget::operate(focus_operation(Id::new(SHARE_SCOPE)));
}
}
// in view: content is Some(..) while open
enz_popover(enz_button("Share", Message::ToggleShare).into_element(), form, || Message::DismissShare)
.label("Share")
.scope(Id::new(SHARE_SCOPE))enz_positioned_overlay places a surface at an app-supplied point instead, clamped to the viewport.
Tooltips
enz_tooltip wraps a control with a tooltip; enz_fade_tooltip fades it. For icon buttons, enz_toolbar_icon(..).label(..) sets the accessible name and tooltip in one call.
Where overlays open
Overlays stay inside the window whenever they fit, flipped or shifted as needed, because a menu hanging past the window looks out of place on tiling window managers. On Wayland, one that does not fit opens past the edge in an xdg_popup surface; on X11 it is drawn inside the window and clipped.
anchored_overlay::set_default_popup_overflow(PopupOverflow::Allowed)lets every overlay leave the window..popup_overflow(..)sets it for one anchored overlay or tooltip;PopupOverflow::Neverkeeps it inside always.ICED_OVERLAY_POPUPS=0draws every overlay inside the window on Wayland too.
Menus opened by a click take the input grab in their popup; tooltips never do.
All menus, popovers, pickers and context menus open with a fade and a small scale from the anchored edge (140 ms), and land at once under reduced motion.