pub struct MaterialDialog<'a> { /* private fields */ }Expand description
Material Design dialog component following Material Design 3 specifications
Dialogs interrupt users with overlaid content that requires a response. They appear above all other content and disable all app functionality when shown.
§Usage Examples
let mut dialog_open = false;
// Basic dialog
let dialog = MaterialDialog::new("my_dialog", "Confirm Action", &mut dialog_open)
.content(|ui| {
ui.label("Are you sure you want to proceed?");
})
.action("Cancel", ActionType::Text, || {
// Cancel action
})
.action("Confirm", ActionType::Filled, || {
// Confirm action
});
dialog.show(ui.ctx());§Material Design Spec
- Max width: 560dp on large screens
- Corner radius: 28dp
- Elevation: 6dp (24dp shadow)
- Surface color background
- Minimum touch target: 48x48dp for actions
Implementations§
Source§impl<'a> MaterialDialog<'a>
impl<'a> MaterialDialog<'a>
Sourcepub fn dialog_type(self, dialog_type: DialogType) -> Self
pub fn dialog_type(self, dialog_type: DialogType) -> Self
Sourcepub fn no_focus_trap(self, no_focus_trap: bool) -> Self
pub fn no_focus_trap(self, no_focus_trap: bool) -> Self
Sourcepub fn max_height(self, height: f32) -> Self
pub fn max_height(self, height: f32) -> Self
Sourcepub fn title_padding(self, padding: [f32; 4]) -> Self
pub fn title_padding(self, padding: [f32; 4]) -> Self
Sourcepub fn content_padding(self, padding: [f32; 4]) -> Self
pub fn content_padding(self, padding: [f32; 4]) -> Self
Sourcepub fn actions_padding(self, padding: [f32; 4]) -> Self
pub fn actions_padding(self, padding: [f32; 4]) -> Self
Sourcepub fn scrollable(self, scrollable: bool) -> Self
pub fn scrollable(self, scrollable: bool) -> Self
Sourcepub fn actions_spacing(self, spacing: f32) -> Self
pub fn actions_spacing(self, spacing: f32) -> Self
Sourcepub fn text_action<F>(self, text: impl Into<String>, action: F) -> Selfwhere
F: FnOnce() + 'a,
pub fn text_action<F>(self, text: impl Into<String>, action: F) -> Selfwhere
F: FnOnce() + 'a,
Sourcepub fn filled_tonal_action<F>(self, text: impl Into<String>, action: F) -> Selfwhere
F: FnOnce() + 'a,
pub fn filled_tonal_action<F>(self, text: impl Into<String>, action: F) -> Selfwhere
F: FnOnce() + 'a,
Sourcepub fn filled_action<F>(self, text: impl Into<String>, action: F) -> Selfwhere
F: FnOnce() + 'a,
pub fn filled_action<F>(self, text: impl Into<String>, action: F) -> Selfwhere
F: FnOnce() + 'a,
Sourcepub fn action<F>(self, text: impl Into<String>, action: F) -> Selfwhere
F: FnOnce() + 'a,
pub fn action<F>(self, text: impl Into<String>, action: F) -> Selfwhere
F: FnOnce() + 'a,
Backward compatibility methods
These methods exist to support older code that used different naming conventions for actions. They are functionally equivalent to the more descriptively named methods introduced later.
§Parameters
text: The text label for the buttonaction: A closure that is called when the button is clicked
§Returns
Self for method chaining
Sourcepub fn primary_action<F>(self, text: impl Into<String>, action: F) -> Selfwhere
F: FnOnce() + 'a,
pub fn primary_action<F>(self, text: impl Into<String>, action: F) -> Selfwhere
F: FnOnce() + 'a,
Sourcepub fn show(self, ctx: &Context)
pub fn show(self, ctx: &Context)
Show the dialog, rendering it in the given context
§Parameters
ctx: The egui context used for rendering the dialog
§Behavior
- The dialog will be displayed as an overlay, blocking interaction with other windows
- Clicking outside the dialog or pressing the escape key will close the dialog
- Action buttons will execute their associated actions when clicked
Auto Trait Implementations§
impl<'a> Freeze for MaterialDialog<'a>
impl<'a> !RefUnwindSafe for MaterialDialog<'a>
impl<'a> !Send for MaterialDialog<'a>
impl<'a> !Sync for MaterialDialog<'a>
impl<'a> Unpin for MaterialDialog<'a>
impl<'a> UnsafeUnpin for MaterialDialog<'a>
impl<'a> !UnwindSafe for MaterialDialog<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.