Skip to content

Dialog

A modal dialog over the window, shown while the dialog key is open.

ui.dialog
if ui.button("Open dialog").outline().clicked() {
ui.open_dialog("rename");
}
ui.dialog("rename").title("Rename").children(|ui| {
ui.text_input(&mut self.name).autofocus();
ui.row().w_fill().gap(8).justify_end().children(|ui| {
let cancel = ui.button("Cancel").outline().clicked();
let save = ui.button("Save").primary().clicked();
if cancel || save {
ui.close_dialog("rename");
}
});
});

API reference

SettingDescription
.title(title: impl Display)The title, which also names the dialog for assistive technology.
.children(f: impl FnOnce(&mut Ui<'a>)Declares the content with f while open.