- Docs
- enzUI framework
- Developers
Theme file
The shared enzui/theme.toml every enzUI app reads, its keys, precedence, error handling and how an app adopts it.
One file, edited by hand or with a theme editor, restyles every enzUI application at once. Apps adopt it through enzui_core::theme_file::integration::ThemeIntegration, so no app needs its own chrome-theme source or loader.
Where it lives
The first regular file found wins, highest precedence first:
$XDG_CONFIG_HOME/enzui/theme.toml, the user's theme.$HOME/.config/enzui/theme.toml, when$XDG_CONFIG_HOMEis unset, empty or relative.<dir>/enzui/theme.tomlfor each entry of$XDG_CONFIG_DIRSin order (/etc/xdgwhen unset), a system or site theme.- No file: the compiled default, enzUI Nebula in the active mode (
enzUI Nebula DarkorenzUI Nebula Light).
Files are not merged across roots. A root that is not an absolute path is ignored, as the XDG Base Directory specification requires. Symlinks are followed, so a dotfile manager can link the file into place.
Shape
# Omitted values inherit from the built-in enzUI Nebula default.
version = 1
name = "My theme"
mode = "system" # "system" (default) | "light" | "dark"
# --- common tokens: one value shared by both colour modes ---
[spacing]
space6 = 14 # the default 12px "medium" gap
[typography]
body_size = 15
weight_semibold = 650 # CSS-numeric, integer only
text_scale = 1.25 # scales every size rung
[motion]
normal_ms = 180
easing = "ease_out" # linear | ease_in | ease_out | ease_in_out
reduced_motion = false
[fonts]
ui = "Adwaita Sans" # or a generic: sans-serif | serif | monospace | cursive | fantasy
monospace = "Iosevka"
[elevation.level2]
blur = 12
y_offset = 3
# --- colours: one branch per mode, both in the same file ---
[light.palette]
accent = "#3584e4"
background = "#ffffff"
[dark.palette]
accent = "#78aeed"
background = "#1b1e24"Rules:
- Colours are mode-scoped. Every
palette.*key goes under[light.…]or[dark.…]. A top-level[palette]is rejected with a diagnostic naming the right table. - Everything else is common. Geometry, typography, motion, fonts, breakpoints, elevation and scrollbar tokens are shared; writing them inside a mode table is rejected the same way.
- The desktop accent fills in. When the file sets no
palette.accentfor the active mode, the desktop's accent colour replaces the built-in accent family. A file accent always wins. [fonts]sits below the desktop. When the desktop selects a UI, document or monospace font, it outranks these keys, and an application override outranks both.- Anything omitted is inherited from the built-in default, key by key. A three-line file is a valid theme.
- Colours are
#rgb,#rgba,#rrggbbor#rrggbbaa. No named colours, functions, expressions, imports or script: the file is data.
The full key list is the registry: enzui_core::theme_file::registry::tokens() returns every path with its scope, kind and range. The loader validates with the same table an editor lists.
Component shapes
[radius] says how round each step is; [shape] says which step each component family uses. Values are step names: none, xs, sm, md, lg, xl, xxl, full (a pill) or window (the window's own radius). These are the defaults:
[shape]
button = "full" # buttons, filter and input chips, pagination cells
button_group = "full"
search_field = "full"
badge = "full"
card = "lg"
checkbox = "full" # "xs" gives rounded squares
field = "md" # text fields, dropdowns, text areas
dialog = "window" # dialogs match the window's corners
popover = "xl"
popup = "lg" # menus, dropdown and suggestion lists, the command palette
row = "md" # rows inside popups, reorderable list rows
tooltip = "md"
tab = "lg" # document tabs
key = "sm" # key caps, shortcut badges
media = "lg" # image viewer, cropper and carouselsA widget whose radius the app pinned keeps it.
Strokes, elevation and grain
[stroke]
hairline = 1 # separators and thin outlines
focus_ring = 3 # keyboard focus rings; the default is 2
[elevation]
button = 1 # 0-5; the default 0 keeps filled buttons flat[grain] shapes the theme's paper grain for surfaces that ask for it (GrainSpec::Theme): intensity, density, scale, opacity, tone (both, dark, light), placement (behind, over), dark_ink, light_ink, frequency, octaves, seed, tile and motion_fps. See Materials.
Window buttons, corners and shadow
[window]
buttons = "desktop" # desktop | close | minimize_close | maximize_close | all
radius = 22 # 0..48 px
frame = "app" # app | opaque | frosted | flat_frosted | subtle | glass | clear
[window_shadow]
size = 20 # 0..64 px; 0 draws none
offset = 2 # -32..32 px
opacity = 0.22 # under the active window
inactive_opacity = 0.11
outline = 0.07 # dark hairline just outside the edge
highlight = 0.06 # light hairline inside the edge, dark mode onlyThese apply to windows that draw their own frame. At buttons = "desktop" the desktop's button layout decides, and Close always shows. A glass frame needs a compositor that paints enzUI glass (enzui-material-v1); elsewhere the frame stays opaque. The drop shadow is Wayland-only; a compositor that decorates windows itself owns the shadow instead.
Typography
The five typography.weight_* keys (weight_regular 400, weight_medium 500, weight_semibold 600, weight_bold 700, weight_extrabold 800) set the weight of each semantic text rung. Values are CSS numeric weights, rounded to the nearest hundred (ties up). A widget that pins a weight in code keeps it.
letter_spacing_* and sizing.row_height are read-only: they are listed and readable, but writing a non-default value is refused with an Unsupported diagnostic, because nothing can render it yet.
Modes
Precedence, highest first:
ENZUI_PROBE_LIGHT=1/ENZUI_PROBE_DARK=1(for deterministic captures; light wins if both are set).ThemeIntegration::set_mode_override(Some(mode))in the app;Noneresumes the file and desktop preference.mode = "light"or"dark"in the file.- The desktop's colour scheme, when
mode = "system"(the default).
Text size
typography.text_scale (0.5–3.0) multiplies every size rung: it is the "Large Text" control for enzUI apps. A pinned rung is a base value the scale multiplies, so body_size = 15 with text_scale = 1.25 resolves to 18.75. Precedence, highest first:
- User:
ThemeIntegration::set_user_text_scale, withdrawn withreset_text_scale. - Theme:
typography.text_scalein the file. An explicit1.0outranks a session that asks for more. - Platform:
ENZUI_TEXT_SCALEwhen set, otherwise the desktop's text scaling factor read through the Settings portal and followed live. - Application: the compiled default from
ThemeIntegrationConfig::application_text_scale(..).
Out-of-range values from the session are clamped; NaN, zero or negative values mean 100%. The scale does not touch the monitor scale, spacing, radii or explicit pixel pins such as EnzText::size_px.
Reduced motion
Precedence, highest first: an in-app ThemeIntegration::set_reduced_motion_override, an explicit motion.reduced_motion in the file (including false), the desktop's request to reduce motion, then the animated default. See Motion.
When the file is wrong
| Fault | Behaviour |
|---|---|
| TOML syntax error | The whole file is rejected. A running app keeps its last known-good theme; a launching app uses the default. |
| Unknown key | Ignored with an UnknownKey diagnostic, so a file from a newer release still loads |
| Wrong type, out of range, bad colour, unknown enum word | That key is dropped (WrongType, OutOfRange, BadColor, BadEnum); every other key applies |
| Colour key at the top level, or common key in a mode table | Dropped, WrongScope, naming the right table |
Missing version | Assumed current, MissingVersion |
version from the future | Known keys still apply, UnknownVersion |
| File over 64 KiB | Refused |
| Unreadable candidate | An Io fault naming that path, with no fall-through to a lower-priority theme |
Saving through ThemeDocument::to_toml keeps comments, key order and keys the build does not understand, and save_theme_atomic replaces the file atomically with mode 0644. Keys are only ever added, never renamed, so themes stay compatible across releases.
Adopting it in an app
use enzui_core::theme_file::integration::{ThemeEvent, ThemeIntegration};
// boot
let (themes, boot) = ThemeIntegration::boot();
(App { themes }, boot.map(|event| Message::Theme(Box::new(event))))
// update
Message::Theme(event) => {
let before = app.themes.theme_generation();
let task = app.themes.update(*event);
if app.themes.theme_generation() != before {
app.invalidate_theme_dependent_caches();
}
task.map(|event| Message::Theme(Box::new(event)))
}
// subscription and iced theme
app.themes.subscription().map(|event| Message::Theme(Box::new(event)))
app.themes.theme().iced_theme()The file is parsed once per change, off the UI thread. The integration watches every candidate path, so creating, replacing, editing or deleting a file re-resolves precedence. status() reports Default, Loaded, LastKnownGood { error } or UnmanagedCompiled, and diagnostics() lists per-key problems.
When theme_generation() changes, invalidate caches that hold font metrics or theme-derived geometry (measured row heights, pagination) and rebuild shell breakpoints from the live theme. Content-only caches such as thumbnails stay valid.
The only opt-out is explicit: ThemeIntegration::unmanaged_compiled_theme(EnzTheme::dark()).