Color Theming
Learn how to configure existing themes and create custom color schemes for your SaaS. Includes light/dark mode support.
RankThis includes a sophisticated theming system with 8 predefined color themes plus light/dark mode support:
- • Code-based configuration - Set default theme in config
- • User preference storage - Themes persist across sessions
- • Light/dark mode toggle - Independent of color theme
- • CSS custom properties - Easy customization
Available Themes
Deep blues and teals. Professional and calming.
Deep purples and cosmic vibes. Modern and mysterious.
Soft purples and celestial tones. Elegant and ethereal.
Warm reds and cherry tones. Energetic and bold.
Rich greens and earth tones. Natural and grounding.
Bright cyans and electric blues. Vibrant and energetic.
Warm oranges and vintage vibes. Nostalgic and friendly.
Neutral grays and minimal colors. Clean and professional.
Configure Default Theme
Change your default theme by modifying the configuration file:
1export const THEME_CONFIG = {2 // Change this string to switch themes3 defaultColorTheme: "ocean", // ← Change this45 persistTheme: true,6 allowThemeSwitching: true,7};
Available options: ocean, cosmic, celestial, cherry, forest, neon, retro, mono
Configuration Options
1export const THEME_CONFIG = {2 // Default color theme when user visits first time3 defaultColorTheme: "ocean",45 // Whether to save user's theme choice6 persistTheme: true,78 // Whether to show theme switcher in UI9 allowThemeSwitching: true,1011 // Default light/dark mode12 defaultMode: "system", // "light" | "dark" | "system"13};
Create Custom Themes
Create custom themes by adding them to the color themes configuration:
1export const colorThemes = {2 // ... existing themes ...34 // Your custom theme5 sunset: {6 light: {7 primary: "25 47% 55%", // Orange-ish8 "primary-foreground": "210 40% 98%",9 secondary: "35 100% 95%", // Light peach10 "secondary-foreground": "25 47% 15%",11 accent: "45 100% 85%", // Warm yellow12 "accent-foreground": "25 47% 15%",13 // ... other CSS custom properties14 },15 dark: {16 primary: "25 85% 60%", // Brighter orange17 "primary-foreground": "25 47% 10%",18 secondary: "25 47% 10%", // Dark background19 "secondary-foreground": "35 100% 95%",20 accent: "25 47% 15%", // Darker accent21 "accent-foreground": "35 100% 95%",22 // ... other CSS custom properties23 },24 },25};
Each theme needs both light and dark variants with these properties:
Core Colors
- •
primary- Main brand color - •
secondary- Supporting color - •
accent- Highlight color - •
background- Page background - •
foreground- Main text
UI Colors
- •
card- Card backgrounds - •
muted- Subtle backgrounds - •
border- Element borders - •
input- Form inputs - •
ring- Focus rings
Colors use HSL format without the hsl() wrapper:
1// ✅ Correct format2primary: "220 50% 50%", // hue saturation lightness34// ❌ Wrong format5primary: "hsl(220, 50%, 50%)",6primary: "#3b82f6",7primary: "rgb(59, 130, 246)",
💡 Use an HSL color picker to get the right values
Light/Dark Mode
Users can toggle between light/dark modes using the theme toggle:
1import { ThemeToggle } from "~/components/ThemeToggle";23// Add to your header or navigation4<ThemeToggle />
The toggle automatically saves user preference and applies it across the site.
Quick Testing
Change defaultColorTheme in config and refresh the page
Check Both Modes
Test your theme in both light and dark modes for consistency
Accessibility
Ensure sufficient contrast ratios for text readability
Component Development Guide
Learn how to create theme-aware components using the triple-color architecture.
RankThis uses three color systems that work together for maximum flexibility:
Dynamic Semantic Colors
- • Auto light/dark switching
- • Semantic naming
- • CSS custom properties
- • Use for: Layout, content
Static Brand Colors
- • Never change
- • Consistent identity
- • Tailwind config
- • Use for: CTAs, logos
Dynamic Color Themes
- • 8 preset themes
- • User-selectable
- • CSS class-based
- • Use for: Accents
✅ Recommended Patterns
1// Theme-aware layout2<div className="bg-background text-foreground border-border">3 <h2 className="text-foreground">Adapts to themes</h2>4 <p className="text-muted-foreground">Subdued text</p>5</div>67// Brand elements (CTAs)8<button className="bg-brand text-brand-foreground">9 Consistent brand button10</button>1112// Theme-adaptive accents13<div className="bg-primary text-primary-foreground">14 Changes with color theme15</div>
❌ Anti-Patterns
1// ❌ Hardcoded colors2<div className="bg-white text-black">3 Breaks in dark mode4</div>56// ❌ Mixed approaches7<div className="bg-background text-blue-500">8 Inconsistent theming9</div>1011// ❌ Inline styles12<div style={{ backgroundColor: '#fff' }}>13 Ignores theme system14</div>
Use these semantic colors for components that adapt to light/dark mode:
Core Colors
backgroundMain backgroundforegroundMain textprimaryTheme accentsecondaryAlt backgroundsUtility Colors
mutedSubdued contentaccentHighlightsdestructiveErrorsborderBordersuseTheme Hook
1import { useTheme } from "~/hooks/useTheme";23export function Component() {4 const { isDark, toggle } = useTheme();56 return (7 <div>8 <p>Mode: {isDark ? 'Dark' : 'Light'}</p>9 <button onClick={toggle}>Toggle</button>10 </div>11 );12}
useColorTheme Hook
1import { useColorTheme } from "~/hooks/useColorTheme";23export function Component() {4 const { colorTheme, setColorTheme } = useColorTheme();56 return (7 <div>8 <p>Theme: {colorTheme}</p>9 <button onClick={() => setColorTheme('ocean')}>10 Switch to Ocean11 </button>12 </div>13 );14}
Always test your components across theme variations:
Testing Checklist
- • ✅ Light mode appearance
- • ✅ Dark mode appearance
- • ✅ All 8 color themes
- • ✅ Color contrast accessibility
- • ✅ Hover/focus states
- • ✅ Mobile responsiveness
Quick Test Wrapper
1// For component testing2<div className="space-y-4">3 <div className="light theme-ocean p-4 border">4 <YourComponent />5 </div>6 <div className="dark theme-cosmic p-4 border">7 <YourComponent />8 </div>9</div>