Skip to main content

Module theme

Module theme 

Source
Expand description

Visual themes — design tokens stored as data, rendered as CSS variables: a Theme holds surface / semantic colors + typography + radii + shadows; BrandColor rows attach N named brand colors per theme, each emitting its own slug-keyed CSS variable triplet (raw / rgb / contrast) plus an auto-derived 50→950 shade scale.

The theme is rendered into a <style> block by emit_css — consumers (admin chrome, public page render) drop the block into <head> and reference var(--color-bg), var(--color-primary) etc. anywhere downstream.

The admin chrome reads Material Design 3 token names (--md-sys-color-surface, --md-sys-color-primary, …), not the legacy --color-* names this module historically emitted. So every block now emits BOTH namespaces: the legacy --color-* for any host crate / public template still reading them, plus the MD3 bridge so picking a different admin theme actually shifts the chrome palette. Container / on-* variants the schema doesn’t carry directly are derived via mix_with_neutral + wcag_foreground.

Structs§

BrandColor
A named brand color attached to a Theme. Each one emits:
Theme
A named design-token bundle. Editors create one per visual style they want to ship: “Teal”, “Forest”, “Aurora Violet”.

Functions§

emit_css
Render a Theme (plus its BrandColor rows) as a <style> block ready to drop into <head>. Emits: