Palette generator

Argot turns a small palette definition (named OKLCH seeds + options) into CSS custom properties: sixteen steps per seed (--name-1 … --name-16) and an unnumbered alias (--name) pointing at the seed’s step.

Use it alone, or drop the CSS into a scaffold’s primitives.css. Palette generation does not write semantic mappings and does not run the processor.

CLI #

argot palette <definition.json> [output.css] [--force] [--dry-run]
Argument / flag Meaning
definition.json Palette definition (required)
output.css Destination (default ./primitives.css)
--force Allow replacing an existing output file
--dry-run Validate and render without writing (still needs --force if the path exists)

Input and output paths must differ. Parent directories are created on a real write. Output directories and unsafe paths are refused.

argot palette ./palette.json
argot palette ./palette.json ./styles/primitives.css
argot palette ./palette.json ./styles/primitives.css --dry-run
argot palette ./palette.json ./styles/primitives.css --force

Definition format #

{
  "version": 1,
  "seedColors": [
    { "name": "gray", "l": 0.6, "c": 0.015, "h": 250 },
    { "name": "brand", "l": 0.6, "c": 0.2, "h": 250 }
  ],
  "options": {
    "lightnessCurve": "inclusive",
    "chromaCurve": "weighted",
    "format": "oklch",
    "gamut": "p3"
  }
}

Seeds #

Each entry in seedColors:

Field Rules
name Color identifier: ^[a-zA-Z][a-zA-Z0-9]*(?:-[a-zA-Z0-9]+)*$ (e.g. blue, brand-primary). No leading --.
l Finite lightness 0–1 (not 0–100)
c Finite, nonnegative chroma
h Finite hue degrees (not wrapped; negatives and values above 360 are kept)

Names must not collide with another seed’s reserved steps. For example, blue and blue-1 cannot both be seed names because blue already emits --blue-1.

Unknown fields and unsupported version values are rejected. Coordinates are not coerced from strings, clamped, or rounded at validation time.

Options #

All optional:

Option Values Default
lightnessCurve uniform, inclusive, centered uniform
chromaCurve centered, weighted centered
format oklch, hex oklch
gamut p3, srgb p3 for OKLCH; srgb for hex

format: "hex" requires gamut: "srgb" (or the default that implies sRGB). Hex with p3 throws.

Curves (behavior) #

Lightness Behavior
uniform Shared lightness ladder across hues; seed may shift slightly to the ladder
inclusive Keeps the seed color in the scale; spaces other steps around it (good for exact brand colors)
centered Places the seed near the middle of the scale
Chroma Behavior
centered Highest chroma near the middle of the scale
weighted Highest chroma near the seed (useful for light/pastel palettes)

After calculation, colors are gamut-mapped and rounded for CSS output. Contrast between semantic pairs is not guaranteed—map semantics and run color-contrast if you need that check.

Output shape #

/* Generated by Argot. */
:root {
  --brand-1: oklch(…);
  /* … --brand-2 … --brand-15 … */
  --brand-16: oklch(…);
  --brand: var(--brand-8);
}

The unnumbered --name alias targets the step nearest the seed (baseStep, one-based, 1–16).

Library API #

Browser-safe (argot-css/palette):

  • normalizePaletteDefinition
  • parseCssColor — CSS color string → { l, c, h } for composing seeds
  • generatePalette — structured scales (raw OKLCH before output mapping)
  • renderPaletteCss / generatePaletteCss

Node only (argot-css/palette/node):

  • loadPaletteDefinition(path)
  • writePalette(outPath, definition, { force?, dryRun? })

Definitions use numeric seeds. If you start from a CSS color, parse first:

import { parseCssColor, generatePaletteCss } from 'argot-css/palette';

const css = generatePaletteCss({
  version: 1,
  seedColors: [{ name: 'brand', ...parseCssColor('#663399') }],
});

Full signatures: package docs/api.md.

Theme Machine #

Interactive palette authoring lives on Theme Machine. Argot’s generator is the headless engine for the same family of curves. Export or hand-author a definition JSON, then generate CSS here—Argot does not embed the Theme Machine UI.

This page drafted by AI and pending human revision.