Skip to main content

set_palette

Function set_palette 

Source
pub fn set_palette(build: fn(Appearance) -> Theme, cx: &mut App)
Expand description

Teach bezel how this app builds its palette, so light/dark switching rebuilds your colours instead of replacing them with the built-in ones.

A palette installed with Theme::install_custom alone lasts only until the appearance changes, because appearance::apply rebuilds from scratch. Registering the builder is what makes brand colours survive:

fn palette(appearance: Appearance) -> Theme {
    let mut theme = Theme::for_appearance(appearance);
    theme.accent = my_brand_accent(appearance);
    theme
}
theme::set_palette(palette, cx);          // before appearance::init

Call it before appearance::init, which installs the first palette. Later than that, follow it with appearance::apply to repaint.