better-colors

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 better-colors-langgenius
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-colors
Source: https://github.com/langgenius/due-date-hq-jwl/tree/main/.claude/skills/better-colors
Command: npx skills add https://github.com/langgenius/due-date-hq-jwl --skill better-colors-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, hue drift across lightness steps, and failing contrast because those color spaces do not match human perception. This Skill applies the OKLCH perceptual color space so palette generation, contrast fixes, and gamut handling behave predictably. ## Core Features & Use Cases - Color Conversion: Convert hex, rgb(), rgba(), hsl(), and hsla() values to oklch() while leaving gradients, keywords, and formatting untouched. - Palette Generation: Build 50–950 numeric scales with clamped lightness bounds, per-step chroma clamping to gamut, multi-hue palettes using equal chroma percentage, and dark mode derivation by reversing lightness mapping. - Contrast & Accessibility: Check foreground/background pairs against APCA Lc thresholds and WCAG 2 ratios, then fix failures by adjusting only the oklch lightness channel. - Gamut & Tailwind v4: Clamp out-of-gamut chroma, add @media (color-gamut: p3) fallbacks, and define custom @theme color scales in oklch. - Use Case: Migrating a design system to Tailwind v4? Convert every hex token in @theme to oklch, rebuild hue-drifting HSL ramps with constant hue, and verify body text reaches Lc 75 against its background. ## Quick Start Convert the hex colors in my stylesheet to oklch and check whether the text colors pass APCA contrast on their backgrounds.

Frequently Asked Questions about better-colors

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, keywords like currentColor, and formatting unchanged.

How do I fix failing text contrast with oklch?

Adjust only the lightness (L) channel to increase the L distance between foreground and background, keeping chroma and hue unchanged. Chroma has negligible effect on contrast, so changing C never fixes a failing pair.

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

APCA uses a perceptual lightness contrast (Lc) score, targeting Lc 75 minimum for body text, while WCAG 2 uses a luminance ratio requiring 4.5:1 for normal text at AA. APCA is more perceptually accurate; WCAG 2 is needed for formal conformance claims.

Does Tailwind v4 support oklch colors in @theme?

Yes, Tailwind CSS v4 defines its default palette in oklch and accepts oklch values in custom @theme tokens such as --color-brand-500. Opacity modifiers like bg-brand-500/50 compile to oklch slash-alpha syntax automatically.

Why do oklch colors sometimes look clipped or dull?

The chroma value exceeds the sRGB gamut maximum for that lightness and hue, so the browser clips it. Reduce chroma while keeping L and H constant, and add a @media (color-gamut: p3) rule to use higher chroma on wide-gamut displays.

How do I detect hue drift in an HSL palette?

Convert each palette step to oklch and compare the H values across steps. If the hue spread exceeds 10 degrees, the palette has visible drift and should be rebuilt with a constant oklch hue.