Accessing the theme
Import the ThemeExt trait to call cx.theme() from any App or Context:
use maccn::theme::ThemeExt as _;
let theme = cx.theme();
let label = theme.label;
let accent = theme.accent;Light and dark appearances
MaccnTheme::light() and MaccnTheme::dark() return the full palette for each appearance. Set the global theme during startup or when the system appearance changes:
use maccn::{MaccnAppearance, MaccnTheme};
let is_dark = true;
cx.set_global(match is_dark {
true => MaccnTheme::dark(),
false => MaccnTheme::light(),
});Accent color
The theme stores one accent color that tints every selected control. maccn ships a small palette in maccn::theme::accent:
use maccn::theme::accent;
use maccn::MaccnTheme;
let mut theme = MaccnTheme::light();
theme.accent = accent::PURPLE;
cx.set_global(theme);Available tokens
MaccnTheme exposes semantic colors such as:
label,label_secondary,label_tertiary,label_disabledwindow_bg,content_bg,control_bg,group_boxcontrol,control_pressed,control_disabledaccent,accent_pressed,accent_disabled,focus_ringseparator,border_controldestructive,destructive_bg
Use these tokens in your own views to stay consistent with the built-in components.