Skip to main content

Module theme

Module theme 

Source
Expand description

Semantic colour keys. Renderers look up named keys rather than hard-coding Color::Green, so users can repaint the whole splash by overriding a handful of tokens in [theme].

Shape of the contract:

  • ColorKey is a static metadata record a renderer declares via Renderer::color_keys. The xtask catalog picks those up so the docs page for every renderer lists the tokens it uses.
  • Theme is the resolved palette passed to every render() call. Callers build it once from ThemeConfig (TOML) via Theme::from_config.

§Default theme — “Splash”

Motif: sunrise over deep ocean. Every token is tuned so the palette reads like one place rather than a grab-bag of accents. Two heroes anchor it — a warm coral for the rising sun (panel_title, errors, hottest heatmap cell) and a cool cyan-teal for sunlit shallows (accent_event, calendar markers). text_dim and text_secondary lean teal so chrome feels like looking up through water. The palette_series cycle stays on the coral↔ocean axis; palette_heatmap climbs night → shallow → sunrise → dawn.

Token families follow a strict prefix scheme so TOML stays grep-able and new tokens slot into an obvious home:

  • bg / bg_subtle — painted surfaces.
  • text / text_dim / text_secondary — body copy and its dimmer variants.
  • panel_border / panel_title — panel chrome.
  • status_ok / status_warn / status_error — badge triad.
  • accent_today / accent_event — calendar / scatter markers.
  • palette_series / palette_heatmap — multi-colour palettes.

Every token is opinionated — the splash owns the entire surface rather than leaking terminal colours through unpainted cells. Users on light terminals (or anyone who’d rather keep their terminal palette) can revert any token with [theme] <name> = "reset" — bg = "reset", text = "reset", etc. — which falls back to Color::Reset for that slot only.

Modules§

presets
Built-in theme presets. Each function returns a fully-populated Theme; [theme] preset = "name" selects one as the base, and any sibling keys in [theme] override individual tokens on top (see super::Theme::from_config).

Structs§

ColorKey
Metadata describing one semantic colour token a renderer consumes. Lives next to the renderer’s declaration so it can’t drift out of sync with what the code actually reads. The xtask docs generator renders these into each renderer’s reference page.
Theme
Resolved palette handed to each render() call. Immutable within a draw cycle.
ThemeConfig
TOML representation of [theme]. Every field optional — omitted keys fall back to the built-in default. ratatui::Color deserializes from both named colours ("green", "dark_gray") and "#RRGGBB" hex, so users don’t need to think about which form.

Constants§

ACCENT_EVENT
ACCENT_TODAY
BG
BG_SUBTLE
PALETTE_HEATMAP
PALETTE_SERIES
PANEL_BORDER
PANEL_TITLE
STATUS_ERROR
STATUS_OK
STATUS_WARN
TEXT
TEXT_DIM
TEXT_SECONDARY

Functions§

token_color
Resolve a single-colour theme token by its TOML key ("text", "panel_title", "status_ok" etc.). Used by renderers that accept a color = "<token>" option; unknown names return None so the caller can fall back to the renderer’s own default.