跳到內容
調色盤星雲光譜
選擇版面配色

即時套用,保留目前的亮暗模式。

色彩與亮暗模式

Astromer 提供基礎 token、語義色盤與元件樣式。整站視覺 Theme 和頁面版型由獨立的 Astrolith 提供;Astromer 元件可讀取選用 Theme 設定的 --am-theme-* aliases。

文件與 Playground 頂部的「調色盤」可將同一元件套用四套配色。每套都調整背景、文字、邊框與輔助色。

調色盤 data-palette 主色方向
星雲光譜 nebula 玫瑰色
星辰編輯 celestial 暖象牙、薰衣草與霧金
星際餘暉 ember 暖金色
紙張工坊 paper 米白、深青與鼠尾草
<html lang="zh-TW" data-palette="celestial" data-theme="dark">

未設定 data-palette 時沿用預設 tokens。文件與 Playground 的選擇器會把選擇存入 astromer-palette;套件 CSS 本身不存取 localStorage。自訂 token 後,請重新檢查文字對比、焦點及狀態辨識。

data-theme 接受 light、dark 或 auto。auto 跟隨系統 prefers-color-scheme。

document.documentElement.setAttribute("data-palette", "ember");
document.documentElement.setAttribute("data-theme", "light");

元件以 light-dark() 與語義 token 取得相應色彩。若應用程式要保存使用者偏好,應在讀回時驗證值。

  1. Primitive — 原色與數值(@astromer/tokens 的 primitives.css)
  2. Semantic — 亮暗模式與色盤語義變數(semantic.css)
  3. Component — 元件級覆寫(例如 --am-button-bg)
  4. 選用 Theme aliases — Astrolith 可設定 --am-theme-*,Astromer 元件使用帶 fallback 的值。

Playground 可在同一元件示範切換色盤與亮暗模式。