diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 9a748b78a39..5fb2d729b72 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -1619,7 +1619,7 @@ impl Context { self.options(|opt| opt.style().clone()) } - /// Mutate the [`Style`] used by all subsequent windows, panels etc. + /// Mutate the [`Style`]s used by all subsequent windows, panels etc in both dark and light mode. /// /// Example: /// ``` @@ -1628,30 +1628,65 @@ impl Context { /// style.spacing.item_spacing = egui::vec2(10.0, 20.0); /// }); /// ``` - pub fn style_mut(&self, mutate_style: impl FnOnce(&mut Style)) { - self.options_mut(|opt| mutate_style(std::sync::Arc::make_mut(&mut opt.style))); + pub fn style_mut(&self, mut mutate_style: impl FnMut(&mut Style)) { + self.options_mut(|opt| { + mutate_style(std::sync::Arc::make_mut(&mut opt.dark_style)); + mutate_style(std::sync::Arc::make_mut(&mut opt.light_style)); + }); + } + + /// The [`Style`] used by all subsequent windows, panels etc in dark mode. + pub fn dark_style(&self) -> Arc