一键导入
theming
Use when semantic roles must map coherently across light, dark, forced-colors, or saved theme preferences without contrast or no-flash regressions.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when semantic roles must map coherently across light, dark, forced-colors, or saved theme preferences without contrast or no-flash regressions.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Imagery, illustration, and iconography direction for web UI. Use for hero images, photo treatment, illustration style, icon sets, favicons, OG/social cards, decorative graphics, image-shaped holes, and removing generic AI imagery.
OKLCH color-system guidance for cohesive palettes and contrast-safe tokens. Use when choosing colors, generating ramps, fixing muddy palettes, creating semantic state colors, checking WCAG contrast, or defining theme variables.
State matrix for interactive UI. Use when building or reviewing buttons, links, inputs, tabs, toggles, menus, cards, or controls that need hover, focus, active, disabled, loading, selected, error, keyboard, or ARIA states.
Honest, Tufte-informed web data visualization. Use for charts, dashboards, metrics, KPI tiles, sparklines, chart accessibility, chartjunk removal, genre choice, lie-factor checks, direct labels, data tables, and themed SVG/HTML.
Design-system interview before new frontend builds or redesigns. Use for vague site/app/landing/dashboard requests, generic-looking UI, direction-setting, aesthetic choices, type/color/density decisions, and DESIGN-SYSTEM.md tokens.
Empty, loading, and error-state design. Use for first-run screens, zero results, empty lists/tables/dashboards, loading skeletons, offline/permission errors, retries, layout stability, and state copy.
| name | theming |
| description | Use when semantic roles must map coherently across light, dark, forced-colors, or saved theme preferences without contrast or no-flash regressions. |
A theme system keeps component roles stable while their values change. Components
reference semantic tokens such as --color-bg, --color-text, and --color-focus;
supported light, dark, or branded modes remap those roles without rewriting components.
This skill builds that system. The hard part isn't the control — it is tuning each supported mapping in context. Dark is not inverted light, an authored high-contrast theme is not forced colors, and no mode earns an accessibility claim without measurement.
--color-bg, --color-surface-1/2 (-3 if elevation needs it),
--color-text, --color-text-muted, --color-border, --color-primary,
--color-primary-hover, --color-primary-ink, --color-accent, --color-accent-ink,
--color-success, --color-error, --color-warning, --color-info,
--color-focus — the canonical contract names). Components
use these only. (Palette comes from color-system.)references/surfaces-and-elevation.md +
color-and-contrast.md.)prefers-contrast: more may
select an authored higher-contrast mapping. forced-colors is a system-controlled
environment: honor system colors instead of treating it as another palette.prefers-color-scheme when applicable;
add a persistent user control when the product supports selectable themes. Set
color-scheme so native controls follow.The starter values demonstrate role mapping and preference order, not a dark-theme recipe. Derive each mapping from the supplied semantic roles, ambient conditions, brand direction, and platform constraints. A credible theme system may use quiet surfaces, high-information field surfaces, or a more editorial reading surface, but it must keep role names, forced-colors respect, preference precedence, and measured pairs intact. When source roles are missing, stop and name the recovery needed rather than inventing raw values in components.
color-scheme declared per theme (native controls/scrollbars follow).forced-colors/high-contrast — don't override system colors there; use
forced-color-adjust only deliberately, keep focus visible.Separate three decisions that are often accidentally merged: stable semantic role names, the values each supported theme maps to those roles, and the policy that chooses a theme at render time. Document the precedence in plain language: system forced-colors takes authority; then an explicit supported user choice; then the operating-system preference; then the application default. When a theme control exists, define its precedence, storage behavior, and no-preference fallback.
Treat forced-colors as an environment, not another palette. Let system colors and native control behavior remain authoritative, and preserve warnings, errors, selections, and focus with text, icons, state, or shape as well as color. If a semantic role is absent, record a failed recovery row and stop the mapping decision; reusing a convenient accent silently changes the role’s meaning.
Minimize wrong-theme flash at the earliest theme application point. State what happens before the first paint, when a saved choice is unavailable, and how native controls receive the matching color-scheme. A preference plan is not a verified no-flash result until a cold-load observation names the theme, artifact, and timing.
Use assets/theme-starter.css as a mapping example. Preserve the invariants that apply
to the supported scope: semantic roles, tuned authored mappings, forced-colors
cooperation, and early preference resolution when a saved choice exists.
Early saved-theme resolution: when a persistent control exists, apply the validated
override before render. In a CSP-compatible implementation, this is commonly a small
nonced or hashed <head> script rather than a deferred bundle:
<script>/* inline, in <head>, before CSS paint */
try {
const t = localStorage.getItem("theme");
if (t === "dark" || t === "light") document.documentElement.dataset.theme = t;
} catch {
/* Storage is unavailable; CSS keeps the OS/application default authoritative. */
}
</script>
Update supported browser chrome where it materially improves the experience. Treat selection and custom scrollbar styling as optional polish, not completion gates.
light-dark() shorthandWhen color-scheme drives the switch (no persisted override), light-dark() avoids
media-query duplication: background: light-dark(oklch(96% .02 78), oklch(18% .024 64)).
Broad browser support (2024+); pair with [data-theme] so explicit user choice and
forced-colors still override. Not the sole mechanism when a manual toggle exists.
references/surfaces-and-elevation.md — the dark surface ramp + elevation-by-
lightness (Material overlay model), borders, why shadows fail on dark.references/color-and-contrast.md — desaturating accents for dark, semantic state
colors per theme, contrast re-testing, OKLCH conversions.references/light-and-contrast.md — contextual light mappings, surface relationships,
accent contrast, and rendered checks.references/high-contrast.md — prefers-contrast + forced-colors/Windows High
Contrast: what to do and what NOT to override.references/decision-records.md — meta-patterns + ADR rules.Close with a five-field evidence ledger. Put the check ID at the start of Reason and name the environment or mode in Evidence.
| Status | Reason | Remediation | Evidence | Provenance |
|---|---|---|---|---|
| role-map — semantic roles across supported themes | ||||
| supported-maps — each requested mode is tuned rather than inverted | ||||
| resolution — preference, no-flash, and native-control behavior | ||||
| forced-colors — high-contrast environmental behavior | ||||
| contrast-handoff — per-theme proof and accessibility boundary |
Report semantic roles, supported mappings, resolution policy, wrong-theme-flash behavior, and per-theme contrast. Include task-level proof for the environments in scope and forced-colors where applicable. Hand source ramps, type, technical a11y, and cognitive concerns to the adjacent skills. Provenance is credited and independent.
Canonical detail: contract.json.
table_with_evidence with status, reason, remediation, evidence, provenance.