Skip to content

色彩

色彩系統

本系統的色彩以三層 design token 架構定義。所有元件透過 Component token 取色,Component token 引用 Semantic token,Semantic token 引用 Primitive token。

Primitive(原始色票)→ Semantic(語意用途)→ Component(元件客製)

主題切換只需覆寫 Semantic 層,所有元件自動生效。


Primitive 色票

原始設計數值,不直接在元件中使用。前綴 --govtw-primitive-color-

7 個色家族各 12 階,套用統一 OKLCH 曲線:

LC用途
1-20.985 / 0.9650.005 / 0.015極淺背景
3-40.93 / 0.8750.035 / 0.060淺底、淺邊框
5-60.79 / 0.690.090 / 0.115標準邊框
7-80.58 / 0.480.135 / 0.145(峰)連結、按鈕 bg
9-100.38 / 0.300.135 / 0.105深強調
11-120.25 / 0.210.085 / 0.070接近最深

色家族 hue:blue 240、teal 170、red 25、green 145、yellow 85、purple 300、neutral 240(chroma ≈ 0.005-0.008,淡 tint 灰)。

Blue(hue 240)

blue-1L 0.985
blue-2L 0.965
blue-3L 0.93
blue-4L 0.875
blue-5L 0.79
blue-6L 0.69
blue-7L 0.58 ← link
blue-8L 0.48 ← button
blue-9L 0.38
blue-10L 0.30
blue-11L 0.25
blue-12L 0.21 ← anchor

Teal(hue 170)

teal-1L 0.985
teal-2L 0.965
teal-3L 0.93
teal-4L 0.875
teal-5L 0.79
teal-6L 0.69
teal-7L 0.58
teal-8L 0.48 ← secondary
teal-9L 0.38
teal-10L 0.30
teal-11L 0.25
teal-12L 0.21

Red(hue 25)

red-1L 0.985
red-2L 0.965
red-3L 0.93
red-4L 0.875
red-5L 0.79
red-6L 0.69
red-7L 0.58
red-8L 0.48 ← error
red-9L 0.38
red-10L 0.30
red-11L 0.25
red-12L 0.21

Green(hue 145)

green-1L 0.985
green-2L 0.965
green-3L 0.93
green-4L 0.875
green-5L 0.79
green-6L 0.69
green-7L 0.58
green-8L 0.48 ← success
green-9L 0.38
green-10L 0.30
green-11L 0.25
green-12L 0.21

Yellow(hue 85)

yellow-1L 0.985
yellow-2L 0.965
yellow-3L 0.93
yellow-4L 0.875
yellow-5L 0.79
yellow-6L 0.69
yellow-7L 0.58
yellow-8L 0.48 ← warning
yellow-9L 0.38
yellow-10L 0.30
yellow-11L 0.25
yellow-12L 0.21
yellow-focus#fd0 ← 特例 (focus)

Purple(hue 300)

purple-1L 0.985
purple-2L 0.965
purple-3L 0.93
purple-4L 0.875
purple-5L 0.79
purple-6L 0.69
purple-7L 0.58
purple-8L 0.48 ← visited
purple-9L 0.38
purple-10L 0.30
purple-11L 0.25
purple-12L 0.21

Neutral(hue 240,極低 chroma)

neutral-1L 0.99 ← bg-canvas
neutral-2L 0.97
neutral-3L 0.94
neutral-4L 0.88 ← divider
neutral-5L 0.78
neutral-6L 0.66
neutral-7L 0.55 ← text-secondary
neutral-8L 0.45
neutral-9L 0.35
neutral-10L 0.27
neutral-11L 0.22
neutral-12L 0.18 ← text-primary

Semantic 色彩

以用途命名,引用 Primitive 層。主題切換(如 dark mode)覆寫的就是這一層。

切換頁面的深色模式可以看到 Semantic 色彩隨主題自動變化。

品牌色

--govtw-color-brand-primary主要品牌色
--govtw-color-brand-secondary輔助品牌色

文字色

--govtw-color-text-primary主要文字
--govtw-color-text-secondary次要文字
--govtw-color-text-on-primary品牌色上的文字

背景色

--govtw-color-bg-canvas頁面背景
--govtw-color-bg-surface區塊背景

邊框色

--govtw-color-border-default預設邊框

回饋色

--govtw-color-feedback-error錯誤
--govtw-color-feedback-success成功
--govtw-color-feedback-warning警告
--govtw-color-feedback-info資訊

連結色

--govtw-color-link-default預設連結
--govtw-color-link-visited已瀏覽連結

Focus

--govtw-focus-color聚焦框色(黃色)

使用方式

元件內部使用 Component token,一般頁面使用 Semantic token:

css
/* 一般頁面樣式 — 使用 Semantic token */
.my-element {
  color: var(--govtw-color-text-primary);
  background: var(--govtw-color-bg-surface);
  border: 1px solid var(--govtw-color-border-default);
}

客製品牌色(覆寫 Semantic token)

各機關只需覆寫 Semantic 層的品牌色,所有元件自動生效:

css
@import '@gov-tw/tokens/tokens.css';

:root {
  --govtw-color-brand-primary: #0062B1;    /* 機關品牌主色 */
  --govtw-color-brand-secondary: #00A67E;  /* 機關品牌輔色 */
}

客製特定元件(覆寫 Component token)

需要細粒度調整時,覆寫單一 Component token,影響範圍只到該元件:

css
:root {
  --govtw-button-primary-bg: #0062B1;
}

無障礙

  • 所有文字與背景色的對比度至少符合 WCAG 2.2 AA 標準(4.5:1)
  • 回饋色不僅依靠色彩傳達意義,需搭配圖示或文字
  • Focus 色 #fd0 確保鍵盤導航時的高可見度