#egui #ui #modal #frame

egui-modal

a modal library for egui

8 releases

0.2.2 Mar 16, 2023
0.2.1 Feb 10, 2023
0.2.0 Jan 23, 2023
0.1.8 Dec 9, 2022
0.1.4 Sep 21, 2022

#20 in #egui

Download history 95/week @ 2022-12-01 119/week @ 2022-12-08 24/week @ 2022-12-15 36/week @ 2022-12-22 25/week @ 2022-12-29 82/week @ 2023-01-05 45/week @ 2023-01-12 74/week @ 2023-01-19 61/week @ 2023-01-26 53/week @ 2023-02-02 75/week @ 2023-02-09 74/week @ 2023-02-16 46/week @ 2023-02-23 29/week @ 2023-03-02 45/week @ 2023-03-09 71/week @ 2023-03-16

197 downloads per month

MIT license

40KB
365 lines

egui-modal, a modal library for egui

crates.io docs license

modal

normal usage:

/* 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(ui, "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.

/* calling every frame */

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

...
...
...

// Show the dialog
dialog.show_dialog();

elsewhere,

/* happens once */
if let Ok(data) = my_function() {
    dialog.open_dialog(
        Some("my_function's result is..."), // title
        Some("my_function was successful!"), // body
        Some(Icon::Success) // icon
    )
}

Dependencies

~3–7MB
~109K SLoC