Skip to main content

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 in src/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:
Usage:

Border Radius System

Consistent corner rounding throughout the app:
Usage with Tailwind:

Dark Mode

Implementation

Dark mode is managed by next-themes with class-based switching:

Theme Toggle

Dark Mode Classes

Use the dark: prefix for dark mode styles:

Changing the Color Palette

Method 1: Edit CSS Variables

Directly modify src/index.css:

Method 2: Use Theme Generator

  1. Visit ui.shadcn.com/themes
  2. Customize colors visually
  3. Copy generated CSS variables
  4. 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

  1. Always pair colors correctly:
    • bg-primary with text-primary-foreground
    • bg-card with text-card-foreground
  2. Test in both modes:
    • Light mode
    • Dark mode
  3. Don’t rely on color alone:
    • Use icons
    • Add text labels
    • Include patterns

Best Practices

bg-primary (theme-aware) ❌ bg-blue-500 (hardcoded)
Every token in light mode should exist in dark mode
Verify WCAG AA compliance for all text colors
Always pair background colors with their foreground counterparts
Supplement color with icons, text, or patterns

Customization Examples

Brand Color Change

Adding Custom Colors

Usage:

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

Resources