class UI::Theme

Overview

UI::Theme is now an adapter over UI::DesignTokens::Tokens. The public API (the #primary, #surface, #font_family, corner_radius_* accessors and the named factories .design_system_default / .apple_default / .material_baseline) is preserved verbatim so existing call sites keep compiling, but every default value is now derived from the canonical UI::DesignTokens::Tokens.default palette and scales.

The Android renderer continues to read brand decisions through this adapter — its visit-method literal-scrub is deferred to a follow-up phase per docs/initiative-cross-platform-ui/handoff/phase-01-architect-scope-deferral-2026-05-20.md.

Defined in:

ui/theme.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.amber_default : Theme #

Web design-system theme. Brand colors and typography track the canonical UI::DesignTokens::Tokens.default.


[View source]
def self.apple_default : Theme #

Apple-style theme (HIG defaults). Derived from UI::DesignTokens::Tokens.default's Apple-leaning typography + corner radii; brand colors mirror Apple's stock System Blue / Red / Gray so existing AppKit callers see no visual change.


[View source]
def self.design_system_default : Theme #

[View source]
def self.from_design_tokens(tokens : UI::DesignTokens::Tokens, font_family : String, body_size : Float64, title_size : Float64, headline_size : Float64, caption_size : Float64, corner_small : Float64, corner_medium : Float64, corner_large : Float64) : Theme #

Build a Theme from a UI::DesignTokens::Tokens instance. Used by the named factories above; also a convenience entry point for downstream apps that want to inject their own branded tokens into the legacy UI::Theme adapter without forking it.


[View source]
def self.material_baseline : Theme #

Material Design 3 baseline theme. Brand colors are derived from UI::DesignTokens::Tokens.default.colors_light.brand_* so a brand override on the unified tokens cascades to this adapter automatically.


[View source]
def self.new #

[View source]

Class Method Detail

def self.amber_tokens : Components::CSS::Tokens::Theme #

[View source]
def self.design_system_tokens : Components::CSS::Tokens::Theme #

[View source]

Instance Method Detail

def background : ThemeColor #

[View source]
def background=(background : ThemeColor) #

[View source]
def corner_radius_large : Float64 #

[View source]
def corner_radius_large=(corner_radius_large : Float64) #

[View source]
def corner_radius_medium : Float64 #

[View source]
def corner_radius_medium=(corner_radius_medium : Float64) #

[View source]
def corner_radius_small : Float64 #

Shape


[View source]
def corner_radius_small=(corner_radius_small : Float64) #

Shape


[View source]
def error : ThemeColor #

[View source]
def error=(error : ThemeColor) #

[View source]
def error_container : ThemeColor #

[View source]
def error_container=(error_container : ThemeColor) #

[View source]
def font_family : String #

Typography


[View source]
def font_family=(font_family : String) #

Typography


[View source]
def font_size_body : Float64 #

[View source]
def font_size_body=(font_size_body : Float64) #

[View source]
def font_size_caption : Float64 #

[View source]
def font_size_caption=(font_size_caption : Float64) #

[View source]
def font_size_headline : Float64 #

[View source]
def font_size_headline=(font_size_headline : Float64) #

[View source]
def font_size_title : Float64 #

[View source]
def font_size_title=(font_size_title : Float64) #

[View source]
def inverse_on_surface : ThemeColor #

[View source]
def inverse_on_surface=(inverse_on_surface : ThemeColor) #

[View source]
def inverse_surface : ThemeColor #

[View source]
def inverse_surface=(inverse_surface : ThemeColor) #

[View source]
def label_primary : LabelRole #

Apple semantic label-color roles. These resolve to dynamic appearance-tracking system colors in the AppKit / UIKit renderers (NSColor.labelColor / UIColor.labelColor and siblings). The stored symbol simply names the role; the renderer owns the lookup.


[View source]
def label_primary=(label_primary : LabelRole) #

Apple semantic label-color roles. These resolve to dynamic appearance-tracking system colors in the AppKit / UIKit renderers (NSColor.labelColor / UIColor.labelColor and siblings). The stored symbol simply names the role; the renderer owns the lookup.


[View source]
def label_quaternary : LabelRole #

[View source]
def label_quaternary=(label_quaternary : LabelRole) #

[View source]
def label_secondary : LabelRole #

[View source]
def label_secondary=(label_secondary : LabelRole) #

[View source]
def label_tertiary : LabelRole #

[View source]
def label_tertiary=(label_tertiary : LabelRole) #

[View source]
def on_background : ThemeColor #

[View source]
def on_background=(on_background : ThemeColor) #

[View source]
def on_error : ThemeColor #

[View source]
def on_error=(on_error : ThemeColor) #

[View source]
def on_error_container : ThemeColor #

[View source]
def on_error_container=(on_error_container : ThemeColor) #

[View source]
def on_primary : ThemeColor #

[View source]
def on_primary=(on_primary : ThemeColor) #

[View source]
def on_primary_container : ThemeColor #

[View source]
def on_primary_container=(on_primary_container : ThemeColor) #

[View source]
def on_secondary : ThemeColor #

[View source]
def on_secondary=(on_secondary : ThemeColor) #

[View source]
def on_secondary_container : ThemeColor #

[View source]
def on_secondary_container=(on_secondary_container : ThemeColor) #

[View source]
def on_surface : ThemeColor #

[View source]
def on_surface=(on_surface : ThemeColor) #

[View source]
def on_surface_variant : ThemeColor #

[View source]
def on_surface_variant=(on_surface_variant : ThemeColor) #

[View source]
def on_tertiary : ThemeColor #

[View source]
def on_tertiary=(on_tertiary : ThemeColor) #

[View source]
def on_tertiary_container : ThemeColor #

[View source]
def on_tertiary_container=(on_tertiary_container : ThemeColor) #

[View source]
def outline : ThemeColor #

[View source]
def outline=(outline : ThemeColor) #

[View source]
def outline_variant : ThemeColor #

[View source]
def outline_variant=(outline_variant : ThemeColor) #

[View source]
def primary : ThemeColor #

Material Design 3 semantic color roles


[View source]
def primary=(primary : ThemeColor) #

Material Design 3 semantic color roles


[View source]
def primary_container : ThemeColor #

[View source]
def primary_container=(primary_container : ThemeColor) #

[View source]
def secondary : ThemeColor #

[View source]
def secondary=(secondary : ThemeColor) #

[View source]
def secondary_container : ThemeColor #

[View source]
def secondary_container=(secondary_container : ThemeColor) #

[View source]
def surface : ThemeColor #

[View source]
def surface=(surface : ThemeColor) #

[View source]
def surface_variant : ThemeColor #

[View source]
def surface_variant=(surface_variant : ThemeColor) #

[View source]
def tertiary : ThemeColor #

[View source]
def tertiary=(tertiary : ThemeColor) #

[View source]
def tertiary_container : ThemeColor #

[View source]
def tertiary_container=(tertiary_container : ThemeColor) #

[View source]
def to_css_custom_properties : String #

Generate CSS custom properties string for web rendering.


[View source]