Color System
The UI Lab design system uses OKLCH, a perceptually-uniform color space, to ensure consistent, accessible colors across all themes and components. This guide documents the complete palette and provides task-focused guidance for using colors in your projects.
Quick Reference
| Family | Purpose | Use Case |
|---|---|---|
| **Background** | Surface and container colors | Page backgrounds, cards, elevated surfaces |
| **Foreground** | Text and icon colors | Body text, labels, icons, borders |
| **Accent** | Interactive elements | Buttons, links, focus indicators |
| **Success** | Positive states (green) | Confirmations, approved actions |
| **Danger** | Error states (red) | Errors, destructive actions, failures |
| **Warning** | Caution states (orange) | Warnings, pending states, alerts |
| **Info** | Neutral information (blue) | Information, documentation, metadata |
Understanding OKLCH
OKLCH is a perceptually-uniform color space designed for human perception. Unlike RGB or HSL, equal steps in lightness produce equal perceived brightness changes, making it possible to build themes programmatically while maintaining visual consistency.
Why OKLCH?
- Perceptual Uniformity: Lightness correlates directly with perceived brightness
- Hue Stability: Colors maintain their character across the entire lightness scale
- Accessible Defaults: All combinations designed for WCAG AA compliance
- Predictable Theming: Dynamic theme generation maintains visual balance automatically
Color Components
Each color consists of three values:
- L (Lightness): 0% (black) to 100% (white) — controls brightness
- C (Chroma): 0 (grayscale) to ~0.4 (saturated) — controls color intensity
- H (Hue): 0° to 360° — the color position on the color wheel
Example: oklch(50% 0.150 25) represents a medium-brightness red with moderate saturation
Complete Color Palette
Below is the comprehensive color palette for all color families. Click any value to copy it to your clipboard.
Color Palette Families
Core Colors
Background — Grayscale palette for surfaces and containers
- Shade Scale: 50 (lightest) to 950 (darkest)
- Usage: Page backgrounds, card surfaces, elevated containers
- Tip: Ensure sufficient contrast with foreground colors for readability
Foreground — Grayscale palette optimized for text and icons
- Shade Scale: 50 (lightest) to 950 (darkest)
- Usage: Body text, labels, icons, borders, dividers
- Accessibility: All shades meet WCAG AAA contrast standards
Accent — Primary interactive color (dynamically themable)
- Shade Scale: 50 (lightest) to 950 (darkest)
- Usage: Primary buttons, links, focus indicators, highlights
- Theming: Can be customized per theme while maintaining accessibility
Semantic Colors
Success (Green, 142° hue) — Positive actions and confirmations
- Chroma Range: 0.01 – 0.28
- Use: Success messages, confirmations, approved states, positive feedback
Danger (Red, 25° hue) — Errors and destructive actions
- Chroma Range: 0.01 – 0.28
- Use: Error messages, destructive action confirmations, failed states
Warning (Orange, 65° hue) — Cautions and attention-needed states
- Chroma Range: 0.01 – 0.26
- Use: Warning messages, pending states, important notices
Info (Blue, 255° hue) — Information and neutral states
- Chroma Range: 0.01 – 0.24
- Use: Info messages, documentation links, neutral metadata
How to Use Colors
Selecting Colors
- Choose the Right Family: Select based on semantic meaning (success, danger, etc.), not appearance
- Pick a Shade: Light backgrounds use 50–300, medium use 400–500, dark use 600–950
- Verify Contrast: Always check that text/background pairs meet WCAG AA (4.5:1 minimum)
- Consider Both Themes: All colors work in light and dark modes
Practical Examples
Success Message
Error/Danger Button
Info Badge
CSS Variables
All colors are available as CSS variables:
Examples: --background-900, --foreground-300, --accent-500, --success-700, --danger-600, --warning-400, --info-500
In CSS:
In React/TSX:
With Tailwind CSS v4:
Accessibility
Contrast Ratios
All color combinations in this palette are designed to meet or exceed WCAG AA standards:
- Normal Text: Minimum 4.5:1 contrast ratio
- Large Text: Minimum 3:1 contrast ratio
- Graphics & UI: Minimum 3:1 contrast ratio
Best Practices
- Never rely on color alone: Always use text labels and icons in addition to color
- Test your combinations: Verify contrast before using in production
- Consider colorblind users: Use semantic colors with supporting icons
- Use sufficient spacing: Help distinguish similarly-colored elements through spacing
Testing Tools
Dynamic Theming
The accent color family can be dynamically customized while maintaining accessibility:
The system automatically:
- Scales chroma appropriately across shades
- Maintains perceptual uniformity
- Respects WCAG AA compliance
- Applies global adjustments consistently
Browser Support
The OKLCH color space is supported in all modern browsers:
- Chrome/Edge 111+
- Firefox 113+
- Safari 15.4+
- All modern mobile browsers
For older browsers, CSS variables fall back to oklch() syntax with fallback values automatically provided.