egui-modal, a modal library for egui

crates.io docs license

modal

normal usage:

```rust /* calling every frame */

let modal = Modal::new(ctx, "my_modal");

// What goes inside the modal modal.show(|ui| { // these helper functions help set the ui based on the modal's // set style, but they are not required and you can put whatever // ui you want inside [.show()] modal.title(ui, "Hello world!"); modal.frame(ui, |ui| { modal.body(ui, "This is a modal."); }); modal.buttons(ui, |ui| { // After clicking, the modal is automatically closed if modal.button("close").clicked() { println!("Hello world!") }; }); });

if ui.button("Open the modal").clicked() { // Show the modal modal.open(); } ```

dialog usage

dialog

in some use cases, it may be more convenient to both open and style the modal as a dialog as a one-time action, like on the single instance of a function's return. ```rust /* calling every frame */

let dialog = Modal::new(ctx, "my_dialog");

... ... ...

// Show the dialog dialog.showdialog(); elsewhere, rust /* happens once */ if let Ok(data) = myfunction() { dialog.opendialog( Some("myfunction's result is..."), // title Some("my_function was successful!"), // body Some(Icon::Success) // icon ) } ```