Expand description
Modal System
A composable modal system with standard dialog patterns.
§Usage
§Basic Modal
use egui_charts::ui_kit::modal::ModalHandler;
// In your state
struct MyState {
delete_modal: ModalHandler<u64>,
}
// Open the modal
state.delete_modal.open_with(item_id);
// Show the modal
state.delete_modal.show(ctx, |ui, payload| {
if let Some(id) = payload {
ui.label(format!("Delete item {}?", id));
if ui.button("Delete").clicked() {
// Handle delete
}
}
});§Confirm Dialog
use egui_charts::ui_kit::modal::dialogs::{ConfirmDialog, ConfirmResult};
let result = ConfirmDialog::new("delete_confirm", "Confirm Delete", "Are you sure?")
.danger()
.confirm_text("Delete")
.show(ctx, &mut open);
match result {
ConfirmResult::Confirmed => { /* delete */ }
ConfirmResult::Cancelled => { /* cancelled */ }
ConfirmResult::None => { /* still open */ }
}§Prompt Dialog
use egui_charts::ui_kit::modal::dialogs::{PromptDialog, PromptResult};
let result = PromptDialog::new("rename_prompt", "Rename Item")
.message("Enter a new name:")
.initial_value(current_name)
.show(ctx, &mut open);
if let PromptResult::Submitted(new_name) = result {
// Handle rename
}Modules§
- dialogs
- Confirmation and text-entry dialogs.
Structs§
- Modal
- A modal dialog widget
- Modal
Handler - Manages modal open/close state
- Modal
Response - Response from showing a Modal
- Simple
Modal - A simple modal that manages its own open state
Functions§
- show_
modal - Helper function to show a centered modal with standard styling