跳到正文
FunCoding

design-derived-themes

Foundational: apply while planning or first building a page or feature, because these choices are expensive to change later. Build a theme system from a few inputs (Linear uses three: accent color, background color, contrast) and derive every other color token from them, instead of hand-defining dozens of variables per theme. Gives users personal themes without letting them make it ugly. Use when adding theming, custom themes, dark mode variants, brand/accent color customization, or when a design has too many hand-picked color tokens.

Star
749
最近提交
2026年11月30日

skills/design-derived-themes/SKILL.md

在 GitHub 上查看

Derived themes

When: upfront, when colors and theming are first set up; converting a pile of hand-picked tokens later is a big job. Fine shade tuning can wait.

Before their redesign, every Linear theme needed 98 variables defined by hand. Now a theme is three inputs: accent, background, contrast. A system derives the ~90 tokens from those. Simple enough to maintain, powerful enough to feel personal, constrained enough that users can't make it look horrible. Related: design-color-on-color (shading on known backgrounds).

How

  • Inputs: --base-bg, --accent, --contrast (a 0–1 or low/normal/high scale). Dark vs light falls out of the background's lightness; don't make it a separate theme.
  • Derive in OKLCH. Surfaces, borders, hover states and text are lightness steps from the background, keeping its hue and a little of its chroma. Text lightness is pushed away from the background by an amount scaled by contrast.
:root {
  --base-bg: oklch(0.99 0.005 260);
  --accent: oklch(0.6 0.18 270);
  --contrast: 1; /* 0.7 low … 1.4 high */
  --dir: 1;      /* -1 when background is dark */

  --bg-raised: oklch(from var(--base-bg) calc(l - 0.02 * var(--dir)) c h);
  --border:    oklch(from var(--base-bg) calc(l - 0.08 * var(--dir) * var(--contrast)) c h);
  --text-2:    oklch(from var(--base-bg) calc(l - 0.45 * var(--dir) * var(--contrast)) calc(c * 2) h);
  --text-1:    oklch(from var(--base-bg) calc(l - 0.8 * var(--dir) * var(--contrast)) c h);
  --accent-hover: oklch(from var(--accent) calc(l + 0.05 * var(--dir)) c h);
}
  • Components use only derived tokens, never raw inputs or literals.
  • Constrain the inputs, not the outputs: clamp background chroma and contrast range so any choice stays readable (check text-1/bg ≥ 7:1 and text-2/bg ≥ 4.5:1 across the range).

Check

  • A new theme = 3 values, no other edits
  • Random input combos stay legible (spot-check extremes: saturated bg, low contrast, very dark)
  • No component references a hard-coded color

相似的 Skill

prototype

MAmattpocock/skills337k近 7 天新增 4,978 个 star

angular-developer

AFaffaan-m/ECC315k近 7 天新增 4,381 个 star

官方

firecrawl-build-scrape

FIfirecrawl/firecrawl215k近 7 天新增 5,595 个 star

精选

theme-factory

为幻灯片、文档和网页套用主题配色与字体,内置 10 套主题。

ANanthropics/skills203k近 7 天新增 3,265 个 star

精选

frontend-design

为界面确定视觉方向和字体,避免模板化的默认样式。

ANanthropics/skills203k近 7 天新增 3,265 个 star

精选

web-artifacts-builder

用 React、Tailwind 和 shadcn/ui 构建多组件页面。

ANanthropics/skills203k近 7 天新增 3,265 个 star