-
Notifications
You must be signed in to change notification settings - Fork 9
Guide Theming
Yororen UI ships with built-in light/dark palettes, but you can also provide your own.
- Yororen UI stores the active palette in a
gpui::GlobalcalledGlobalTheme. - Components access it via
ActiveTheme(cx.theme()).
If you install the default global theme:
use gpui::App;
use yororen_ui::theme::GlobalTheme;
fn init_theme(cx: &mut App) {
cx.set_global(GlobalTheme::new(cx.window_appearance()));
}Yororen UI will choose Theme::default_light() or Theme::default_dark() based on the current
WindowAppearance.
Use ThemeSet + GlobalTheme::new_with_themes.
- Light theme is required.
- Dark theme is optional.
- If you do not provide a dark theme, Yororen UI will always use the light theme (even when the system/window appearance is dark).
use gpui::App;
use yororen_ui::theme::{GlobalTheme, Theme, ThemeSet};
fn init_theme(cx: &mut App) {
let light = Theme::default_light();
// Optional:
let dark = Theme::default_dark();
cx.set_global(GlobalTheme::new_with_themes(
cx.window_appearance(),
ThemeSet::new(light).dark(dark),
));
}use gpui::App;
use yororen_ui::theme::{GlobalTheme, Theme, ThemeSet};
fn init_theme(cx: &mut App) {
let light = Theme::default_light();
// No `.dark(...)`.
cx.set_global(GlobalTheme::new_with_themes(
cx.window_appearance(),
ThemeSet::new(light),
));
}Yororen UI's Theme is not just a "primary color". It's a full color contract used across
components.
When you provide a custom theme, you must provide a complete Theme value for the light palette
(and optionally another complete Theme for the dark palette).
-
surface-
canvas: app/window background -
base: default surface background (cards/inputs) -
raised: elevated surface (popovers/title areas) -
sunken: recessed surface (tracks, wells) -
hover: hover surface fill
-
-
content-
primary: primary text -
secondary: secondary text -
tertiary: tertiary/hint text (placeholders) -
disabled: disabled text -
on_primary: text on top ofaction.primary.bg -
on_status: text on top ofstatus.*.bg
-
-
border-
default: default border -
muted: muted border -
focus: focus ring / focused border -
divider: divider line
-
-
action-
neutral,primary,danger(each is anActionVariant)
-
-
status-
success,warning,error,info(each is aStatusVariant)
-
-
shadowelevation_1elevation_2
Each action variant must provide:
bghover_bgactive_bgfgdisabled_bgdisabled_fg
Each status variant must provide:
bgfg
- Ensure adequate contrast for at least these pairs:
-
surface.basevscontent.primary -
action.neutral.bgvsaction.neutral.fg -
action.primary.bgvsaction.primary.fg -
status.*.bgvsstatus.*.fg
-
- Keep
content.on_primary/content.on_statusas "text on top of a solid color" values.
Yororen UI v0.3.0 · repository · Apache-2.0 · This wiki documents Yororen UI v0.3.0.
This wiki documents Yororen UI v0.3.0 — the headless-core, swappable-renderer build.