oklch-skill

Convert CSS colors to oklch and generate perceptually uniform palettes with contrast checks.

3|Updated Apr 20, 2026
One-click install
npx skills add https://github.com/langgenius/due-date-hq-jwl --skill oklch-skill-langgenius
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: oklch-skill
Source: https://github.com/langgenius/due-date-hq-jwl/tree/main/.claude/skills/oklch-skill
Command: npx skills add https://github.com/langgenius/due-date-hq-jwl --skill oklch-skill-langgenius

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? CSS colors written in hex, rgb, or hsl produce broken palettes, failing contrast, and hue drift because those color spaces do not match human perception. This Skill converts colors to the perceptually uniform oklch space and provides rules for palettes, contrast, and gamut handling. ## Core Features & Use Cases - Color Conversion: Convert hex, rgb(), rgba(), hsl(), and hsla() values to oklch() syntax, including bulk file conversion while preserving gradients and CSS keywords. - Palette Generation: Generate 50–950 numeric color scales with clamped lightness bounds and per-step chroma clamping, plus multi-hue palettes and dark mode derivation. - Contrast & Accessibility: Check foreground/background pairs against APCA and WCAG 2 thresholds and fix failures by adjusting only the oklch lightness channel. - Gamut & Tailwind v4: Clamp out-of-gamut chroma for sRGB, add Display P3 fallback patterns with @media (color-gamut: p3), and define custom @theme color scales for Tailwind v4. - Use Case: When migrating a stylesheet to Tailwind v4, convert every hex token in @theme to oklch, verify text contrast against APCA thresholds, and add P3 enhancements for wide-gamut displays. ## Quick Start Convert the hex colors in my stylesheet to oklch and check that the text colors pass APCA contrast against their backgrounds.

Frequently Asked Questions about oklch-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert hex colors to oklch in CSS?

Replace each hex value with its oklch(L C H) equivalent, for example #3b82f6 becomes oklch(0.623 0.188 259.815). Convert only the color values and leave gradient functions, CSS keywords like currentColor, and surrounding structure unchanged.

How do I fix failing text contrast with oklch?

Adjust only the lightness (L) channel to increase the distance between foreground and background, keeping chroma and hue unchanged since chroma has negligible effect on contrast. On light backgrounds (L > 0.85) keep foreground L below 0.45; on dark backgrounds (L < 0.25) keep foreground L above 0.75.

What is the difference between APCA and WCAG 2 contrast ratios?

APCA measures perceptual lightness contrast (Lc) and is the recommended default: normal text passes at |Lc| 60 and passes plus at 75. WCAG 2 uses a luminance ratio required for formal conformance claims: 4.5:1 AA and 7:1 AAA for normal text.

Does Tailwind v4 support oklch colors?

Yes, Tailwind CSS v4 defines its default palette in oklch, and custom @theme scales should use oklch values such as --color-brand-500: oklch(0.623 0.188 250). Opacity modifiers like bg-brand-500/50 compile to oklch slash-alpha syntax automatically.

Why do oklch colors clip or look wrong on some displays?

High-chroma oklch values can exceed the sRGB gamut, whose maximum chroma varies by lightness and hue (cyan clips earliest, purple latest). Clamp chroma to the maximum for the given L and H, and wrap wider-gamut P3 values in an @media (color-gamut: p3) block with an sRGB fallback.

Why use oklch instead of hsl for color palettes?

HSL hue drifts across lightness steps (a blue ramp can shift 18 degrees toward purple) and equal HSL lightness values have wildly different perceived brightness. OKLCH keeps hue constant across the full lightness range and makes equal lightness steps equally bright.