颜色与对比度
在 HEX、RGB、HSL 和 OKLCH 之间转换颜色,并检查在浅色和深色背景下的 WCAG 2.1 对比度。
完全在浏览器中运行 — 粘贴的内容不会被上传。
普通文本需要 4.5 : 1(AA)或 7 : 1(AAA)。大号文字和 UI 边框需要 3 : 1。
:root {
--color-brand: #3B82F6;
--color-brand-rgb: 59 130 246;
--color-brand-hsl: hsl(217, 91%, 60%);
--color-brand-oklch: oklch(62.3% 0.188 259.8);
}@theme {
--color-brand: #3B82F6;
}
text-brand bg-brand border-brand
text-[#3B82F6] bg-[#3B82F6]WCAG 对比度参考
快速参考- 4.5 : 1
- AA 级别普通正文的最低比值,适用于 24px 常规或 18.66px 粗体及以下。
- 3 : 1
- 大号文字以及 UI 组件边框和图标在 AA 级别的最低比值。
- 7 : 1
- 任意字号文字的 AAA 标准;大号文字达到 4.5 : 1 即为 AAA。
- (L1 + 0.05) / (L2 + 0.05)
- 对比度公式,其中 L 是经过伽马校正的相对亮度。
- #RRGGBBAA
- 八位十六进制增加 alpha 通道;CSS rgb() 使用 0-255 数值和 0-1 的 alpha。
- OKLCH
- 感知上均匀的明度与彩度,相同步长看起来相同,色相也能保持对比度。
React 相关语法指南
全部 React 指南React 19 Ref Cleanup Functions and forwardRef Deprecation
ref is a normal prop now and a ref callback may return a cleanup function, which breaks every implicit-return callback. Migration steps and the leak it fixes.
ReactReact 19 Hydration Mismatch: Error 418 and 421 Root Causes
React discards the server HTML as soon as the first client render differs. The deterministic-value fixes for #418, the attribute mismatch behind #421, and how to read the diff.
ReactReact Maximum Update Depth Exceeded: Finding the Update Loop
Fifty nested updates and React gives up. The loop is always a new identity: an inline object in a dependency array, a setState in render, or a selector that returns a fresh array.
ReactReact Profiler API: Measuring Render Timings and Identifying Wasted Re-Renders
actualDuration versus baseDuration, phase names that tell you who triggered a commit, and how to ship the numbers without flooding a backend.