Skip to content
Back to skills

Color Themes

ASecurity

Algorithmic colour theme generation in OKLCH — harmonic schemes, palettes derived from an image, dark/light/auto architecture, and contrast checked before a token ships rather than after. Use when the palette is computed rather than chosen — generating a token set from one brand hue, deriving colours from an image, building a theme switcher, returning harmonic schemes from a function. Not for applying a palette that already exists (design-system).

  • 11 stars
  • 0 votes
  • 2 copies
  • 6 views
  • Added October 22, 2026
ai-agentsgo

Works with

  • cli

Security analysis

A100/100

Pro scans all 15 files and shows the line behind each finding

Scanned October 22, 2026

npx -y skills add Krishna-Modi12/frontend-design-pro --skill color-themes --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Color Themes?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Color Themes
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/krishna-modi12-color-themes/badge)](https://www.skillsdirectory.com/skills/krishna-modi12-color-themes)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: color-themes
description: Algorithmic colour theme generation in OKLCH — harmonic schemes, palettes derived from an image, dark/light/auto architecture, and contrast checked before a token ships rather than after. Use when the palette is computed rather than chosen — generating a token set from one brand hue, deriving colours from an image, building a theme switcher, returning harmonic schemes from a function. Not for applying a palette that already exists (design-system).
metadata:
  version: "15.0.0"
  core-deps:
    - core/design-tokens.md
    - core/accessibility-baseline.md
---

# Color Themes

## When to Use
The palette is *computed*, not chosen: generating a full token set from one brand hue, deriving colours from an uploaded image, building a theme switcher, or producing harmonic schemes on demand. Anything where a function returns colours.

If the palette already exists and only needs applying, that is `design-system`. If the question is which hue suits a brand, that is a judgement call and belongs in `design-principles`. If the palette is to be derived from a specific painting, film grade, editor theme or other aesthetic lineage, the extraction protocol and the licensing catch for each source are in `../design-system/references/brand-extraction.md` — bring the ramp back here to convert it into OKLCH and measure it.

## Core Rules
1. **Generate in OKLCH, always.** It is perceptually uniform: equal lightness steps look equal, and changing hue at fixed lightness does not change apparent brightness. HSL does neither — `hsl(60, 100%, 50%)` yellow and `hsl(240, 100%, 50%)` blue claim the same lightness and differ by roughly 4:1 in fact. Every generated ramp built on HSL is wrong in a way its author cannot see.
2. **Clamp chroma to what the gamut holds.** OKLCH describes colours sRGB cannot display. Past roughly C 0.37 at mid lightness the browser clips, and two different generated colours silently become the same rendered one. Clamp, or verify the result round-trips.
3. **Contrast is computed, not hoped for.** A generated pair must be *measured* before it becomes a token. A theme generator that emits an untested surface/text pair has moved the accessibility failure from design time to runtime, where nobody is looking.
4. **Never average pixels to find a palette.** The mean of a photograph is always the same muddy brown-grey. Cluster — median cut or k-means — and take cluster centroids.
5. **Theme switches are instant.** A 300ms colour transition across a whole document reads as a rendering fault, not as polish. Switch the token values; do not animate them.
6. **Colour is never the only signal.** A generated palette cannot know that red means error. Pair every colour-coded state with a label, an icon, or a shape.
7. **`auto` is a third state, not the absence of a choice.** Store `"light" | "dark" | "auto"`. Storing only a resolved boolean means a user who chose "follow the system" is silently pinned the first time the system flips.

## Patterns
- **Derive the ramp from one anchor.** Take the brand hue, then generate surface/elevated/border/muted/text by moving lightness on a fixed curve and *reducing* chroma as lightness approaches either end. Constant chroma across a ramp produces neon highlights and muddy shadows.
- **Hue wheel for schemes.** Complementary +180°, triadic ±120°, analogous ±30°, split-complementary ±150°. In OKLCH these stay equal-weight, which is exactly what the same rotation in HSL fails to do.
- **Dark mode is not inverted light mode.** Invert lightness, then *lower* chroma — saturated colour on a dark surface glows and vibrates. Roughly 0.75× is a sound starting point.
- **Elevation by lightness, not by shadow, on dark themes.** A raised surface is a lighter surface; drop shadows are close to invisible against near-black.
- **Emit CSS custom properties, not inline styles.** One `:root` block per theme means the switch is one class change rather than a re-render.

## Reference Index
| File | Load when |
|---|---|
| `references/oklch-theme-engine.md` | Generating a token set or a harmonic scheme from an anchor colour |
| `references/image-palette-extraction.md` | Deriving colours from an uploaded image or a photograph |
| `references/accessibility-aware-schemes.md` | Checking a generated pair, APCA vs WCAG, `prefers-contrast` |
| `references/dark-light-auto-architecture.md` | Wiring the switcher, storage, SSR, and avoiding the flash of wrong theme |
| `../design-system/references/brand-extraction.md` | The anchor is to come from a painting, a film grade or an editor theme rather than a brand hue |

## Anti-Patterns
- Raw hex anywhere in generated output. The whole point is a colour space you can reason about.
- A ramp built by changing HSL lightness only — the steps are visually uneven and the mid-tones go grey.
- Averaging an image's pixels for a "dominant colour".
- Transitioning `background-color` on `:root` when the theme changes.
- Persisting a resolved `isDark` boolean instead of the user's actual three-way choice.
- Generating a palette and shipping it without ever measuring a contrast value.

Files in this skill

  • SKILL.md5 KB
  • examples/_r3f-jsx.d.ts1.6 KB
  • examples/_stubs.d.ts658 B
  • examples/bad-hex-theme.tsx3.3 KB
  • examples/bad-low-contrast-theme.tsx3.3 KB
  • examples/good-image-palette.test.tsx3.9 KB
  • examples/good-image-palette.tsx12 KB
  • examples/good-oklch-theme-generator.test.tsx3.5 KB
  • examples/good-oklch-theme-generator.tsx11.7 KB
  • examples/good-theme-toggle.test.tsx3.4 KB
  • examples/good-theme-toggle.tsx8.6 KB
  • references/accessibility-aware-schemes.md5.6 KB
  • references/dark-light-auto-architecture.md5.6 KB
  • references/image-palette-extraction.md6 KB
  • references/oklch-theme-engine.md7.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.