Expand description
Blinc Theme System
A comprehensive theming system with design tokens, platform-native themes, and system dark/light mode detection.
§Overview
The theme system provides:
- Design tokens: Colors, typography, spacing, radii, shadows, animations
- Platform themes: Native look and feel for macOS, Windows, Linux, iOS, Android
- Color scheme detection: Automatic detection of system dark/light mode
- Dynamic overrides: Runtime customization without layout rebuilds
§Quick Start
ⓘ
use blinc_theme::{ThemeState, ColorToken};
// Initialize theme at app startup
ThemeState::init_default();
// Access theme in widgets
let theme = ThemeState::get();
let primary_color = theme.color(ColorToken::Primary);
let spacing = theme.spacing();§Architecture
The theme system is designed to minimize UI rebuilds:
- Visual tokens (colors, shadows): Changes trigger repaint only
- Layout tokens (spacing, typography): Changes trigger partial layout
§Tokens
Tokens are the atomic values that make up the design system:
ColorTokens: Semantic colors (primary, error, background, text, etc.)TypographyTokens: Font families, sizes, weights, line heightsSpacingTokens: 4px-based spacing scaleRadiusTokens: Border radiiShadowTokens: Box shadowsAnimationTokens: Durations and easings
§Themes
Built-in themes:
BlincTheme: Default theme derived from Catppuccin design system- Platform-specific themes for macOS, Windows, Linux, iOS, Android
§Dynamic Overrides
Override tokens at runtime without full rebuilds:
ⓘ
let theme = ThemeState::get();
// Override a color (repaint only, no layout)
theme.set_color_override(ColorToken::Primary, Color::from_hex(0xFF5500));
// Override spacing (triggers partial layout)
theme.set_spacing_override(SpacingToken::Space4, 20.0);
// Clear all overrides
theme.clear_overrides();Re-exports§
pub use platform::detect_system_color_scheme;pub use platform::Platform;pub use state::set_redraw_callback;pub use state::ThemeState;pub use theme::ColorScheme;pub use theme::Theme;pub use theme::ThemeBundle;pub use themes::platform::platform_theme_bundle;pub use themes::BlincTheme;pub use tokens::*;