We can implement theme method in Sandbox to return the desired theme.
use iced::{Sandbox, Settings};
fn main() -> iced::Result {
MyApp::run(Settings::default())
}
struct MyApp;
impl Sandbox for MyApp {
type Message = ();
fn new() -> Self {
Self
}
fn title(&self) -> String {
String::from("My App")
}
fn update(&mut self, _message: Self::Message) {}
fn view(&self) -> iced::Element<Self::Message> {
"Hello".into()
}
fn theme(&self) -> iced::Theme {
iced::Theme::Dark
// or
// iced::Theme::Light
}
}
➡️ Next: Changing Styles
📘 Back: Table of contents