Overview
Zarna uses a sophisticated theme system built on CSS Variables and the OKLCH color space for better perceptual uniformity and dark mode support.Color System
Why OKLCH?
OKLCH (Oklab with Lightness, Chroma, and Hue) provides several advantages over traditional RGB/HSL:- Perceptual uniformity: Colors appear equally bright at the same lightness value
- Better gradients: Smooth color transitions without muddy midpoints
- Predictable manipulation: Adjusting lightness creates natural color variations
- Wide gamut: Supports P3 displays for richer colors
Color Structure
All colors are defined as CSS custom properties insrc/index.css:
Color Tokens
Semantic Color Usage
background
Page background color
foreground
Primary text color
primary
Brand color for CTAs
secondary
Secondary actions
muted
Subtle backgrounds and muted text
accent
Highlight and emphasis
destructive
Dangerous actions (delete, remove)
border
All borders
input
Input field borders
ring
Focus indicators
card
Card backgrounds
popover
Popover backgrounds
Chart Colors
For data visualization with Recharts:Border Radius System
Consistent corner rounding throughout the app:Dark Mode
Implementation
Dark mode is managed bynext-themes with class-based switching:
Theme Toggle
Dark Mode Classes
Use thedark: prefix for dark mode styles:
Changing the Color Palette
Method 1: Edit CSS Variables
Directly modifysrc/index.css:
Method 2: Use Theme Generator
- Visit ui.shadcn.com/themes
- Customize colors visually
- Copy generated CSS variables
- Paste into
src/index.css
Method 3: Programmatic Generation
Understanding OKLCH Values
Lightness (L)
- Range: 0 to 1
- 0: Pure black
- 0.5: Medium brightness
- 1: Pure white
Chroma (C)
- Range: 0 to 0.4 (typically)
- 0: Grayscale (no color)
- 0.1: Subtle color
- 0.2: Moderate saturation
- 0.3+: Vivid colors
Hue (H)
- Range: 0 to 360 degrees
- 0/360: Red
- 120: Green
- 240: Blue
- 60: Yellow
- 180: Cyan
- 300: Magenta
Examples
Tools
OKLCH Color Picker
- oklch.com - Interactive color picker
- Shows RGB fallbacks
- P3 gamut visualization
Theme Testing
Test your theme in both modes:Accessibility
Contrast Requirements
Follow WCAG AA standards:- Normal text: 4.5:1 contrast ratio minimum
- Large text (18pt+): 3:1 contrast ratio minimum
- UI components: 3:1 contrast ratio minimum
Testing Contrast
Ensuring Accessibility
-
Always pair colors correctly:
bg-primarywithtext-primary-foregroundbg-cardwithtext-card-foreground
-
Test in both modes:
- Light mode
- Dark mode
-
Don’t rely on color alone:
- Use icons
- Add text labels
- Include patterns
Best Practices
Use semantic color tokens
Use semantic color tokens
✅
bg-primary (theme-aware)
❌ bg-blue-500 (hardcoded)Maintain color parity
Maintain color parity
Every token in light mode should exist in dark mode
Test contrast ratios
Test contrast ratios
Verify WCAG AA compliance for all text colors
Use foreground pairs
Use foreground pairs
Always pair background colors with their foreground counterparts
Avoid color-only indicators
Avoid color-only indicators
Supplement color with icons, text, or patterns
Customization Examples
Brand Color Change
Adding Custom Colors
Next Steps
Components
Learn how components use the theme system
Best Practices
Follow coding standards for theming
Project Structure
See where theme files are located
Tech Stack
Explore theming libraries
