-
How can I toggle dark theme similarly to the egui demo and in the repo's README. How do I change the theme to dark mode? I'm not asking about how to make a toggle button. I am asking how I can toggle the dark mode. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
use eframe::egui::{Style, Visuals};
let native_options = eframe::NativeOptions::default();
eframe::run_native(
"test",
native_options,
Box::new(|creation_context| {
let style = Style {
visuals: Visuals::dark(),
..Style::default()
};
creation_context.egui_ctx.set_style(style);
Box::new(<ur struct>)
}),
); Or ui.style_mut().visuals = Visuals::dark(); |
Beta Was this translation helpful? Give feedback.
-
If you want to toggle theme globally // ctx: egui::Context
ctx.set_visuals(Visuals::dark()); |
Beta Was this translation helpful? Give feedback.
-
The previous answers did not work for me. As of Nov 2024 this variation of willser's answer works: eframe::run_native(
"test",
native_options,
Box::new(|creation_context| {
creation_context.egui_ctx.set_theme(egui::Theme::Dark);
Box::new(<ur struct>)
}),
); |
Beta Was this translation helpful? Give feedback.
Or