0PricingLogin
Learn Rust Coding · Lesson

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

  1. Immediate-Mode UI Basics
  2. Widgets and Layout
  3. Managing App State
  4. Packaging a Desktop App
← Back to Learn Rust Coding