OKLCH React Color Engineuse-oklch-palette v0.1

Stop hand-tuning hex codes. Generate perceptually uniform 12-step OKLCH palettes in one hook.

An intelligent TypeScript color engine and React hook for design engineers tired of repetitive default palettes and broken dark-mode contrast.

pnpm add @karan-ui/colors
GitHubโ˜… 1,842Component Registry
Interactive OKLCH Studio & Harmonic Presets

Drag the Evil Martians-style gradient tracks below or choose from curated harmonic presets.

Curated Harmonic Presets
Lightness (L)
55% (0.55)
Chroma (C)
0.240
Hue (H)
264ยฐ
83%Standard
Harmony & Contrast ScorecardEvil Martians Aligned

Real-time perceptual uniformity, WCAG AAA contrast, and gamut integrity across Light & Dark modes.

Luminance99%
APCA Readability98%
Gamut Safety33%
Hue Spacing86%
PressSpaceto roll
Trophies:
APCA 100% Unlocked
Chroma Master
Tailwind Escape Artist
Space Explorer
Harmonic Resonance
Interactive Visual Challenge

Standard Tailwind HSL vs. OKLCH Perceptual Engine

In standard sRGB/HSL palettes like Tailwind, step 500 has wildly uneven perceived brightness across hues. Our OKLCH engine locks exact luminance parity across all 6 tones.

Standard Tailwind v3/v4 HSLUneven Luminance Delta: 37%
yellow-500Perceived Lightness: 82%
Contrast: 1.4:1 (FAILS)Unreadable text!
blue-500Perceived Lightness: 45%
Contrast: 4.8:1 (PASS)Darker surface

โš ๏ธ Notice how Yellow-500 is blindingly light ($L = 0.82$) while Blue-500 is dark ($L = 0.45$). Putting white text on both yields broken accessibility.

Our OKLCH Engine (Step 9)Uniform Luminance: 0% Delta
yellow-9Perceived Lightness: 58%
Contrast: 7.8:1 (AAA)APCA Auto-Inverted
blue-9Perceived Lightness: 58%
Contrast: 7.2:1 (AAA)APCA High Contrast

โœจ Both hues share calibrated perceived luminance ($L = 0.58$), and text automatically inverts with APCA hue-aware thresholds for guaranteed AAA readability.

Twelve-Step Semantic Scale Matrix (6 ร— 12)72 Live Calibrated Swatches

Modeled after the Radix Colors 12-step hierarchy. Click any swatch to open the precision inspector with WCAG/APCA ratings and code exports.

Showing: dark Mode Scale
Tone
1-2 Canvas
3-5 Surfaces
6-8 Borders
9-10 Fills
11-12 Text
neutral
primary
success
info
warning
danger
Live Component Bento Grid (Real Applications)100% Dynamic Theme Binding

All 4 cards react to live OKLCH tokens emitted by the generator. Observe contrast hierarchy across surfaces, buttons, text, and data badges.

git:main / commit:b4e892c
1.24s build
Compiled 72 OKLCH tokens successfully
Optimized static bundle for Cloudflare Pages
Production release synced to edge global CDN
https://oklch-engine.pages.dev
Real-time Performance
+24.8% delta
48,290 req/sP99 response time: 8.4ms ยท Zero latency drift
โ— API 100% Healthyโ— P3 Gamut Readyโ— 2 Pending Reviews
Security & Deploy Keys
Validated
Verified
Two-Factor AuthenticationProtect deployment tokens
Automated Git Push HooksDeploy on commit to main
Delete Deployment Pipeline
Spotlight Command Palette
Shortcut:โŒ˜K
Deploy to Cloudflare Pages
โŒ˜D
Export OKLCH CSS Variables
โŒ˜E
Toggle Light / Dark Mode
โŒ˜T
Inspect Accessibility Score
โŒ˜A
Dual Export & React Hook TabsZero-Install Ready

Seamlessly switch between React TypeScript hook integration and zero-install CSS / Tailwind / W3C Tokens.

ThemeProvider.tsx
import { useOklchPalette } from '@karan-ui/colors/react';

export function ThemeProvider({ children }: { children: React.ReactNode }) {
  const { tokens, cssVariables, mode, setMode } = useOklchPalette({
    mode: 'dark',
    tones: {
      neutral: { l: 0.22, c: 0.015, h: 264 },
      primary: { l: 0.55, c: 0.24, h: 264 },
      success: { l: 0.68, c: 0.170, h: 155 },
      info:    { l: 0.66, c: 0.160, h: 294 },
      warning: { l: 0.76, c: 0.170, h: 85 },
      danger:  { l: 0.62, c: 0.210, h: 25 },
    },
    tint: 20,
    chroma: 80,
  });

  return (
    <div style={cssVariables} className={mode}>
      {children}
    </div>
  );
}