Understanding Design Tokens
Design tokens are the visual design atoms of ProComponents. They define colors, spacing, typography, and other design decisions that create a consistent look and feel.Token Hierarchy
ProComponents extends Ant Design’s token system with three layers:- Global Tokens: Ant Design’s base tokens (colors, spacing, typography)
- Pro Tokens: ProComponents-specific tokens (
proComponentsCls,antCls) - Layout Tokens: Specialized tokens for layout components (header, sider, page container)
Using ProConfigProvider
TheProConfigProvider is your gateway to customizing ProComponents theming:
Theme Modes
Dark Mode
Enable dark mode across your entire application:Algorithm Merging
ProConfigProvider automatically merges theme algorithms when dark mode is enabled:Customizing Layout Tokens
Layout tokens provide fine-grained control over ProLayout appearance.Header Customization
Create a custom header theme:Sidebar (Sider) Customization
Customize the sidebar menu appearance:PageContainer Customization
Real-World Example: Custom Theme
Here’s a complete example inspired by the ProComponents demos:Color Utilities
ProComponents provides utility functions for color manipulation:setAlpha
Add transparency to any color:lighten
Adjust color brightness:These utilities use @ctrl/tinycolor internally and support all color formats: hex, rgb, rgba, hsl, hsla, and named colors.
Token Computation
ProComponents computes final tokens through a multi-stage process:The merge() Utility
Themerge() function performs a deep merge that:
- Merges nested objects recursively
- Overwrites arrays (doesn’t concatenate)
- Preserves
nullandundefinedvalues - Handles multiple merge sources
CSS-in-JS Styling
ProComponents uses@ant-design/cssinjs for dynamic styling:
Using the useStyle Hook
Style Layers
Styles are registered in a specific layer for proper CSS cascade:Hash ID Management
Hash IDs provide style isolation in production:- Enable Hashing
- Disable Hashing
- Auto Mode
Advanced: Custom Prefix
Customize the component class prefix:Changing
prefixCls affects all ProComponents within the provider. Use this for white-labeling or avoiding style conflicts.TypeScript Support
ProComponents provides full TypeScript support for tokens:Next Steps
Architecture Overview
Learn about ProComponents architecture and design philosophy
Internationalization
Add multi-language support to your application