🎨 Color Shade & Tint Generator
Mix a base colour with white for lighter tints and with black for darker shades to build a coordinated ladder for buttons and backgrounds.
📐 工作原理與說明
tint = C·(1−t) + 255·t;shade = C·(1−t) + 0·t(t 為混合比例,0 ≤ t ≤ 1)
線性模式在 sRGB 各通道直接混入白/黑;感知模式轉到 OKLCH,僅按感知明度 L 取等步長並保留色相,明度更均勻、避免中段發灰。OKLCH 結果超出 sRGB 色域時按 CSS Color 4 方式裁剪到可顯示範圍,並標註發生裁剪的色卡;色卡同時給出與白/黑文字的對比度。
設計變數(CSS 自定義屬性)
字首 + 檔位命名,可直接粘進設計系統
Formula & Standard References
| Item | Formula / Note | Source / Standard |
|---|---|---|
| Lightness shift | hold hue and saturation, step lightness to build tints and shades | CSS Color Module Level 4 |
| Linear blending | C = C1 x (1 - t) + C2 x t with t as the mix ratio | CSS Color Module Level 4 color-mix() |
| Contrast retention | shades must still meet the 4.5:1 readability requirement | WCAG 2.2 (1.4.3) |
⚠️ 使用說明與注意事項
- tint 是基色混入白色(t→1 越亮),shade 是基色混入黑色(越暗),線性混合即可獲得平滑過渡。
- HEX 支援 3 位簡寫(如 #F60)與 6 位標準寫法,工具會自動展開。
- 無障礙配色建議保證文字與背景的對比度(WCAG AA 至少 4.5:1),不要只看美觀。
📋 說明
左→右為由淺(tint)到基色再到深(shade)的漸變;每側檔數即混入白/黑的比例步數。
設計系統(如 Tailwind 的 50–900)常用這種按明度分檔的色板組織方式。