Immediate-Mode UI Basics
Understand how egui renders.
What Immediate Mode Means
egui is an immediate-mode GUI library. Unlike retained-mode toolkits (GTK, Qt) where you build a persistent widget tree, egui rebuilds the entire UI from scratch on every frame.
Your code runs top-to-bottom each frame, emitting widgets as function calls. There is no stored node graph — the UI is just a side effect of running your closure.
The Update Loop
An egui app implements eframe::App, whose update method is called once per frame, typically 60 times a second.
Inside update you describe what the UI should look like right now, given current state. egui diffs nothing — it simply re-emits everything.
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _f: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.label("Hello, egui!");
});
}
}All lessons in this course
- Immediate-Mode UI Basics
- Widgets and Layout
- Managing App State
- Packaging a Desktop App