Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 917 Bytes

changing_themes.md

File metadata and controls

43 lines (30 loc) · 917 Bytes

Changing Themes

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
    }
}

Changing themes

➡️ Next: Changing Styles

📘 Back: Table of contents