跳到正文
Skillpedia
界面(UI/UX)75k · #2776

color-oklch

它能做什么

这项技能说明如何在 oklch 色彩空间中定义颜色,这种空间与人眼对亮度的感知相符。适合构建设计系统或无障碍调色板的设计师和开发者。

适用场景

  • ✓当你为品牌颜色构建一组亮色和暗色色阶时。
  • ✓当不同颜色的悬停和按下状态看起来不均匀时。
  • ✓当你希望暗色模式的调色板保持一致的感知亮度时。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/color-oklch/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/color-oklch/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2776
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能