Design Philosophy
ProComponents follows several core principles that guide its architecture:1. Build on Top of Ant Design
ProComponents extends Ant Design’s component ecosystem rather than replacing it. Every ProComponent wraps and enhances Ant Design components with additional functionality:- Token System Integration: Inherits and extends Ant Design’s design token system
- ConfigProvider Compatibility: Works seamlessly with Ant Design’s configuration context
- Theme Synchronization: Automatically syncs with Ant Design’s theme algorithm
2. Provider-Based Configuration
The library uses React Context to provide global configuration, similar to Ant Design’sConfigProvider but with additional enterprise features.
Architecture Layers
ProComponents is organized into distinct architectural layers:Core Provider Layer
The foundation of ProComponents is theProConfigContext, which manages:
- Design Tokens: Extended token system with ProComponents-specific tokens
- Internationalization: Built-in i18n support with 35+ locales
- Theme Management: Dark/light mode and custom theme algorithms
- Hash ID Generation: CSS-in-JS with optional hashing for style isolation
Component Layer
ProComponents provides high-level components organized by function:Token System
ProComponents extends Ant Design’s token system with layout-specific tokens:- Header Tokens
- Sider Tokens
- PageContainer Tokens
CSS-in-JS and Style System
ProComponents uses@ant-design/cssinjs for dynamic styling with several key features:
Style Registration
TheuseStyle hook registers component styles with the theme system:
Hash ID System
Styles are isolated using hash IDs in production to prevent conflicts:You can disable hash IDs by setting
hashed={false} on ProConfigProvider, useful for testing or when you need predictable class names.Token Computation and Merging
ProComponents uses a sophisticated token merging strategy:- Base Tokens: Start with Ant Design’s design tokens
- Custom Tokens: Apply user-provided token overrides
- Layout Tokens: Compute layout-specific tokens with
getLayoutDesignToken() - Deep Merge: Use the
merge()utility to combine all token layers
State Management
ProComponents uses SWR (Stale-While-Revalidate) for data fetching and caching:- Automatic Caching: Request results are cached to minimize network calls
- Auto Revalidation: Data is revalidated when the window regains focus
- Cache Cleanup: Optional
autoClearCacheprop clears cache on unmount
Class Naming Convention
ProComponents follows a consistent class naming pattern:- Prefix:
.ant-pro(customizable viaprefixClsprop) - Component: Component-specific identifier (e.g.,
card,table,layout) - Element: Sub-element within component (e.g.,
header,body,footer) - Modifier: State or variant (e.g.,
selected,hover,dark)
.ant-pro-card-header-bordered
Performance Optimizations
Memoization Strategy
ProComponents extensively usesuseMemo and useCallback to prevent unnecessary re-renders:
Token Caching
TheuseCacheToken hook from @ant-design/cssinjs ensures tokens are only recomputed when dependencies change:
Browser Support
ProComponents targets modern browsers:- Chrome (last 2 versions)
- Firefox (last 2 versions)
- Safari (last 2 versions)
- Edge (last 2 versions)
- Electron (last 2 versions)
Internet Explorer support was dropped in ProComponents 3.0. Use version 2.x if IE11 support is required.
Next Steps
Theming System
Learn how to customize ProComponents with the design token system
Internationalization
Explore built-in i18n support for 35+ languages