blinc_theme
Part of the Blinc UI Framework
This crate is a component of Blinc, a GPU-accelerated UI framework for Rust. For full documentation and guides, visit the Blinc documentation.
Theme system for Blinc UI with design tokens and platform-native themes.
Overview
blinc_theme provides a comprehensive theming system with design tokens for colors, typography, spacing, and more. It supports automatic light/dark mode detection and platform-specific themes.
Features
- Design Tokens: Colors, typography, spacing, radii, shadows, animations
- Platform Themes: Native look for macOS, Windows, Linux, iOS, Android
- Color Schemes: Automatic light/dark mode detection
- Dynamic Updates: Runtime theme changes without layout rebuild
- Token Categories: Visual tokens (repaint only) vs layout tokens
Quick Start
use ;
// Get current theme
let theme = current;
// Use theme tokens
let bg_color = theme.colors.background;
let text_color = theme.colors.foreground;
let radius = theme.radius.md;
let spacing = theme.spacing.lg;
Color Tokens
use ColorToken;
// Semantic colors
Background
Foreground
Primary
Secondary
Accent
Muted
MutedForeground
Destructive
Border
Ring
Card
CardForeground
Popover
PopoverForeground
Typography Tokens
use TypographyToken;
// Font sizes
Xs // 12px
Sm // 14px
Base // 16px
Lg // 18px
Xl // 20px
Xl2 // 24px
Xl3 // 30px
Xl4 // 36px
Spacing Tokens
use SpacingToken;
Xs // 4px
Sm // 8px
Md // 12px
Lg // 16px
Xl // 24px
Xl2 // 32px
Xl3 // 48px
Radius Tokens
use RadiusToken;
None // 0px
Sm // 2px
Md // 6px
Lg // 8px
Xl // 12px
Full // 9999px (pill shape)
Color Scheme
use ;
// Get system preference
let scheme = detect_system_color_scheme;
// Set color scheme
set_color_scheme;
set_color_scheme;
set_color_scheme; // Follow system
// Check current scheme
if is_dark_mode
Custom Themes
use ;
// Override specific tokens
set_overrides;
Platform Detection
use Platform;
match current
Architecture
blinc_theme
├── tokens/
│ ├── colors.rs # Color tokens
│ ├── typography.rs # Typography tokens
│ ├── spacing.rs # Spacing tokens
│ ├── radius.rs # Border radius tokens
│ └── shadows.rs # Shadow tokens
├── schemes/
│ ├── light.rs # Light theme
│ └── dark.rs # Dark theme
├── platforms/
│ ├── macos.rs # macOS theme
│ ├── windows.rs # Windows theme
│ └── ...
└── state.rs # Global theme state
License
MIT OR Apache-2.0