Kael’s theme system is the single source of truth for every visual decision in your application. ADocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Augani/kael/llms.txt
Use this file to discover all available pages before exploring further.
Theme value holds five typed sub-structs — ThemeColors, ThemeTypography, ThemeSpacing, ThemeRadii, and ThemeShadows — and plugs directly into GPUI’s global state so that any component can read the active theme from any context. Changes propagate automatically: swap the global and every window refreshes.
Theme
Theme is the root struct. It derives Clone, Debug, PartialEq, serde::Serialize, and serde::Deserialize, and implements the Global marker trait so it can be stored with cx.set_global / cx.global.
rust
Theme::default() delegates to Theme::light().
Constructors
Returns the built-in light theme derived from
Colors::light().Returns the built-in dark theme derived from
Colors::dark().Inspects
window.appearance() and returns Theme::light() for WindowAppearance::Light or WindowAppearance::VibrantLight, and Theme::dark() for WindowAppearance::Dark or WindowAppearance::VibrantDark. Use this to match the OS preference when a window first opens.rust
Parsing
Deserializes a
Theme from a JSON string. Returns an error if parsing fails.Deserializes a
Theme from a TOML string. Returns an error if parsing fails.Reads a file and deserializes it as JSON or TOML. The format is determined from the file extension (
.json / .toml). For unknown extensions, Kael sniffs the content — trying JSON first if the trimmed content starts with {, otherwise TOML first — and returns both error messages if neither succeeds.Global state
Installs the theme runtime into the app. You must call this once at startup, before any component reads the active theme.
Theme::init does three things:- Subscribes an observer on
Themeglobal changes that callssync_theme_colorsand refreshes all windows. - Sets the
Themeglobal toTheme::default()if one is not already present. - Syncs the initial
GlobalColorsfrom the current theme.
rust
cx.observe_theme_file calls Theme::init internally, so you do not need to call it separately when using hot-reload.Hot-reload
App::observe_theme_file watches a JSON or TOML file and re-applies the theme every time the file changes on disk.
rust
ThemeColors
Semantic color tokens mapped from the underlyingColors palette.
rust
The primary application background color.
The default elevated or contained surface color (maps from
Colors::container).The primary interactive emphasis color (maps from
Colors::selected).A secondary accent color for links or highlighted details (also maps from
Colors::selected in the built-in palette).The muted or disabled foreground color (maps from
Colors::disabled).The default readable foreground color (maps from
Colors::text).The shared border color.
The color used for dividers and separators.
The foreground color used on selected or primary-colored surfaces.
The error status color. Defaults to
#dc2626.The warning status color. Defaults to
#f59e0b.The success status color. Defaults to
#16a34a.An open-ended map of project-specific color tokens. Serialize as a TOML table or JSON object under the
custom key.ThemeTypography
Font settings for UI and code content.rust
The font family for general UI text. Defaults to
".SystemUIFont", which resolves to the OS system UI font on every supported platform.The default font weight for UI text. Defaults to
FontWeight::NORMAL.The base font size for UI text. Defaults to
px(14.).The default line height for UI text. Defaults to
px(20.).The font family for code and monospace content. Defaults to
"Menlo".The font size for code content. Defaults to
px(13.).ThemeSpacing
A six-stop spacing scale for layout gaps and component insets.rust
cx.global::<Theme>().spacing.md wherever you need a consistent gap between elements.
ThemeRadii
Corner radii for surfaces, cards, and pill shapes.rust
ThemeShadows
Three elevation levels expressed asBoxShadow tokens.
rust
BoxShadow has fields color: Hsla, offset: Point<Pixels>, blur_radius: Pixels, spread_radius: Pixels, and inset: bool.
Reading the active theme from a component
rust
Updating the theme at runtime
rust