Theming
Learn how to customize and extend the ReacUI design system to match your brand
Overview
ReacUI is built with a flexible theming system that allows you to customize the look and feel of all components to match your brand's identity. The theming system is built on top of Tailwind CSS, making it easy to extend and customize.
Simple Configuration
Customize your theme with a simple configuration file that extends Tailwind CSS.
Design Tokens
Use design tokens to maintain consistency across your application's UI.
Dark Mode Support
Built-in dark mode support with seamless transitions between light and dark themes.
Pro Tip
The theming system is designed to work with Tailwind CSS out of the box. If you're already using Tailwind, you can seamlessly integrate ReacUI into your existing theme.
Theme Configuration
ReacUI's theming is powered by Tailwind CSS. To customize the theme, you'll need to modify your tailwind.config.js file. This allows you to change colors, typography, spacing, and more.
Key Configuration Areas
Colors
Define your brand colors in the colors section. ReacUI uses these color scales:
primary: Brand colors, calls-to-actionsecondary: UI text, borders, backgrounds- Semantic colors: success, warning, error, info
Typography
Customize fonts, sizes, weights, and line heights:
fontFamily: {
sans: ['Inter', 'sans-serif'],
mono: ['Fira Code', 'monospace'],
},
fontSize: {
xs: ['0.75rem', { lineHeight: '1rem' }],
sm: ['0.875rem', { lineHeight: '1.25rem' }],
base: ['1rem', { lineHeight: '1.5rem' }],
lg: ['1.125rem', { lineHeight: '1.75rem' }],
xl: ['1.25rem', { lineHeight: '1.75rem' }],
// ...etc
}Spacing & Sizing
Control margins, padding, width, and height:
spacing: {
px: '1px',
0: '0',
0.5: '0.125rem',
1: '0.25rem',
// ...continues with 1.5, 2, etc.
},Breakpoints
Define responsive breakpoints:
screens: {
sm: '640px',
md: '768px',
lg: '1024px',
xl: '1280px',
'2xl': '1536px',
},Color System
ReacUI uses a systematic approach to colors. Each color in the palette includes a range of shades from 50 (lightest) to 950 (darkest), giving you fine-grained control over your UI.
Default Color Palette
Primary Colors
Secondary Colors
Success
Warning
Error
Customizing Colors
To customize the color palette, replace the default colors with your brand colors in the Tailwind configuration. It's recommended to use a complete scale for each color to ensure proper contrast in different UI states.
Custom Brand Colors
Purple Brand (Primary)
Default Button
Purple Button
Color Accessibility
When customizing colors, ensure they meet WCAG accessibility guidelines for contrast. Tools like Color Review can help you check contrast ratios.
Dark Mode
ReacUI has built-in support for dark mode using Tailwind's dark mode feature. The dark mode is implemented using the 'class' strategy, allowing you to toggle it programmatically.
Dark Mode Implementation
Light Mode
Dark Mode
Dark Mode Design Principles
Don't Just Invert Colors
Dark mode isn't just about swapping light for dark. Use slightly desaturated colors and reduce contrast for text and UI elements to reduce eye strain.
Test for Accessibility
Ensure your dark theme maintains sufficient contrast ratios for text and interactive elements. What works in light mode may not work in dark mode.
Avoid Pure Black
Use dark grays (like #121212 or #1e1e1e) instead of pure black for backgrounds. Pure black can cause eye strain and create too much contrast.
Use Shadows Carefully
In dark mode, reduce shadow opacity and blur. Consider using lighter shadows on dark backgrounds for better depth perception.
Custom Themes
Create custom themes by extending the base theme with your own design tokens. This approach allows you to maintain consistency across your application while providing flexibility for different visual styles.
Theme Selector Component
Create a theme selector component to allow users to switch between different themes:
Theme Preview
This is a message box
Component-Specific Styling
ReacUI components are designed to be easily customizable through props and class names. Here are some common patterns for customizing specific components.
Button Variants
Button Style Examples
Default Variant
Custom Gradient
Size Variants
Custom Classes
Card Component Styling
Card Style Examples
Default Card
Default card with standard styling
Primary Card
Custom primary themed card with shadow
Best Practices
Use Design Tokens for Consistency
Define all your colors, spacing, typography, and other design variables as tokens in your theme configuration. This ensures consistency across your application and makes it easier to update your design system.
Create Component Abstractions
Build component abstractions that encapsulate styling logic. Use utility libraries like class-variance-authority (cva) to create reusable component variants rather than repeating the same class combinations.
// Good: Encapsulated button styles <Button variant="primary" size="lg" /> // Avoid: Repeating class combinations <button className="px-4 py-2 bg-primary-600 text-white rounded-md hover:bg-primary-700" />
Test All Color Modes
Always test your components in both light and dark mode. A design that looks good in light mode might have contrast or readability issues in dark mode, and vice versa.
Design for Accessibility First
Ensure your theme meets WCAG accessibility guidelines. Pay special attention to color contrast ratios, font sizes, and interactive states to ensure your UI is accessible to all users.
Common Pitfalls to Avoid
Hardcoding Colors
Avoid using hardcoded color values like #3b82f6 directly in your components. Always use theme tokens (bg-primary-600) instead.
Overriding Core Components
Avoid directly modifying core component files. Instead, create wrapper components or use composition to extend functionality while keeping the original components intact.
Ignoring Dark Mode
Don't assume everyone uses light mode. Always design and test for both light and dark themes to ensure a good user experience for all users.
Too Many Custom Variants
Don't create a unique variant for every special case. Stick to a reasonable number of reusable variants, and use composition or local customization for edge cases.
Theme Configuration Checklist
- Define a coherent color palette with primary, secondary, and semantic colors
- Configure typography with consistent font families, sizes, weights, and line heights
- Set up a consistent spacing system for margins, padding, and layout
- Define border radius values that match your design language
- Configure shadows for elevation and depth
- Test all components in both light and dark mode
- Verify accessibility compliance for all theme variations