color-oklch
它能做什么
这项技能说明如何在 oklch 色彩空间中定义颜色,这种空间与人眼对亮度的感知相符。适合构建设计系统或无障碍调色板的设计师和开发者。
适用场景
- ✓当你为品牌颜色构建一组亮色和暗色色阶时。
- ✓当不同颜色的悬停和按下状态看起来不均匀时。
- ✓当你希望暗色模式的调色板保持一致的感知亮度时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/color-oklch/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为我的设计系统用 oklch 构建一组蓝色调色板,包含十个间距均匀的色阶。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会把颜色令牌转换为 oklch,在每个色阶上为各种色相保持一致的明度值,并可以为支持广色域的屏幕提供范围更广的颜色。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use oklch() and oklab() for perceptually uniform colour palettes
HSL and hex colours are defined in the sRGB colour space, which is not perceptually uniform — a 10 % lightness change looks dramatically different depending on the hue. This makes creating accessible, harmonious palettes by hand extremely difficult. oklch corrects this: adjusting the L channel produces the same perceived brightness change regardless of hue or chroma, making it far easier to build accessible colour ramps, dark-mode palettes, and consistent hover/active states.
Quick Reference
- oklch(L C H) — Lightness, Chroma, Hue — is the most practical perceptually uniform colour space for design systems
- Equal lightness steps in oklch look equal to the human eye; equal steps in hsl do not
- Define your colour palette tokens in oklch custom properties
- Use @media (color-gamut: p3) to serve wide-gamut colours to capable displays
Check
Check whether the CSS colour tokens use oklch() or a perceptually uniform colour space, or whether they use hsl/hex which may produce inconsistent perceived lightness across hues.
Fix
Convert the colour token palette from hsl/hex to oklch, ensuring the lightness (L) axis is consistent across all hues in the same shade step.
Explain
Explain what perceptual uniformity means in colour spaces, why oklch is better than hsl for design systems, and how the L, C, H channels map to human colour perception.
Code Review
Review CSS custom properties for colour tokens. Flag palette definitions in hsl or hex that use hardcoded values without a systematic lightness ramp, especially if they are intended to be interchangeable shade steps.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/css/color-oklch
常见问题
为什么 hsl 不够用?
这项技能说明,hsl 不具备感知均匀性,因此明度变化 10% 在不同色相上看起来可能差别很大。
L、C 和 H 分别代表什么?
分别是明度、彩度和色相,即 oklch 颜色的三个组成部分。
可以为部分屏幕提供范围更广的颜色吗?
可以。这项技能提到了一个色域媒体查询,可以为支持的显示器提供广色域颜色。
详情
作者的原始描述
Use when building a design token system, creating accessible colour palettes, generating colour ramps programmatically, or migrating a design system to support wide-gamut displays.
热度
- GitHub 星标
- 75k
- 排名
- #2776
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。