pub struct Theme {
pub id: ThemeId,
pub appearance: ThemeAppearance,
pub colors: ColorTokens,
pub layout: LayoutTokens,
pub typography: TypographyTokens,
pub shape: ShapeTokens,
pub motion: MotionTokens,
pub style_slots: ComponentStyleSlots,
pub extensions: ThemeExtensions,
}Fields§
§id: ThemeIdStable identity of this theme — see ThemeId. Serde-defaulted so
older serialized themes (which predate the field) still deserialize.
appearance: ThemeAppearance§colors: ColorTokens§layout: LayoutTokens§typography: TypographyTokens§shape: ShapeTokens§motion: MotionTokens§style_slots: ComponentStyleSlotsTyped Rc<dyn FooStyle> slot bag for theme-wide style
installations. None per slot means “use the widget’s local
Recipe*Style default”; apps install per-theme overrides via
theme.style_slots.button = Some(Rc::new(MyButton)). Per-call
.style(...) on a widget always wins over the slot.
extensions: ThemeExtensionsImplementations§
Source§impl Theme
impl Theme
Sourcepub fn new(
appearance: ThemeAppearance,
colors: ColorTokens,
layout: LayoutTokens,
typography: TypographyTokens,
shape: ShapeTokens,
motion: MotionTokens,
) -> Self
pub fn new( appearance: ThemeAppearance, colors: ColorTokens, layout: LayoutTokens, typography: TypographyTokens, shape: ShapeTokens, motion: MotionTokens, ) -> Self
Build a Theme from raw token data. Most apps go through a
preset constructor (e.g. teksilo_core::presets::intui::light)
rather than calling this directly — presets aggregate the
matching Recipe*Style defaults under the same call.
Sourcepub fn with_id(self, id: impl Into<Cow<'static, str>>) -> Self
pub fn with_id(self, id: impl Into<Cow<'static, str>>) -> Self
Set this theme’s ThemeId and return self for chaining. Used by
preset constructors and apps building custom themes.
Sourcepub fn is_dark(&self) -> bool
pub fn is_dark(&self) -> bool
Whether this theme paints on a dark background. Convenience for
theme.appearance.is_dark().
Sourcepub fn for_inactive_window(&self) -> Theme
pub fn for_inactive_window(&self) -> Theme
A copy of this theme projected for an inactive window — the accent
family and focus indicators desaturated toward graphite (see
ColorTokens::for_inactive_window).
The paint walker swaps this in when the host window loses focus, so every
accent-coloured control greys out with no per-widget code. Only the
colours change; typography / layout / shape / motion are untouched, so
this never affects layout.
Sourcepub fn for_high_contrast(&self) -> Theme
pub fn for_high_contrast(&self) -> Theme
Project into a high-contrast variant (WCAG 1.4.6 Enhanced / EN 301 549
§11.7), applied at paint time when the OS “increase contrast” preference
is set. See
ColorTokens::for_high_contrast.
Sourcepub fn extension<T: Any + Send + Sync>(&self) -> Option<&T>
pub fn extension<T: Any + Send + Sync>(&self) -> Option<&T>
Look up a typed theme extension. See ThemeExtensions.
Sourcepub fn with_extension<T: Any + Send + Sync>(self, value: T) -> Self
pub fn with_extension<T: Any + Send + Sync>(self, value: T) -> Self
Attach a typed extension and return self for chaining. See
ThemeExtensions.