theme-config.json reference

Every field of theme-config.json, from seeds and settings to type, spacing, shape, elevation, vision palettes, layout and output.

theme-config.json is the single input to cortex. Every field has a default: the loaders and mergeThemeConfig merge your file over defaultThemeConfig, so you only write what you change. In practice that starts with seeds.primary, seeds.secondary and seeds.neutral. (validateThemeConfig, which does not merge, requires those three seeds.)

Every path that reads a config validates it with the same Zod schema: mergeThemeConfig, validateThemeConfig, mergeWithDefaults, loadConfigFromPath and ThemeEngine throw a ZodError (or an error naming the file) with the path of each bad field; loadUserConfig prints a CONFIG_LOAD_FAILED warning and falls back to the defaults. Unknown keys are errors, so a typo such as seeds.primay is caught rather than ignored.

The full schema lives in packages/cortex/src/theme/schema/index.ts. Cortex also ships it as a JSON Schema, generated from that Zod schema, so an editor completes the file and checks names, types, enums and simple ranges as you type. The rest is checked when the config is loaded: rules that span fields or need the engine (an ordered scale, a reference to a named entry, frosted glass’s opacity floor), and three single-field rules the JSON Schema does not express (no number beyond ±1,000,000, CSS-safe free text, the characters allowed in name). Name the schema in the optional $schema field, which the engine ignores. The JSON Schema requires seeds.primary, seeds.secondary and seeds.neutral:

jsonc
{
  "$schema": "./node_modules/@flexpixels/cortex/theme-config.schema.json",
  "seeds": { "primary": "#4F46E5", "secondary": "#7C3AED", "neutral": "#334155" },
}

The examples on this page are JSONC, and so may your file be: loadUserConfig and loadConfigFromPath accept // and /* */ comments and trailing commas. JSON.parse does not, and neither does an editor that checks a .json file against $schema as strict JSON, so strict JSON is the portable form.

name

jsonc
{ "name": "FlexPixelsSystem" }

string, default "FlexPixelsSystem". Written into the header comment of the generated CSS and the title of the DESIGN.md export. It may not contain /*, */, {, }, <, > or line breaks.

settings

jsonc
{
  "settings": {
    "prefix": "fp",
    "accessibility": "AA",
    "contrastAlgorithm": "apca",
    "schemes": "both",
  },
}
FieldTypeDefaultNotes
prefixstring"fp"CSS variable prefix: letters, digits and single hyphens, starting with a letter. @flexpixels/ui reads --fp-*; with its components, change it only if you provide --fp- aliases yourself.
accessibility"AA" | "AAA""AA"The ratio checkContrast and ThemeEngine#getContrast require (4.5:1 or 7:1), and the value of the --fp-contrast-threshold token (0.6 or 0.45, full stylesheet only). It also raises the floors the engine solves to: --fp-{role}-text reaches 7:1 on the page, --fp-{role}-border and the matrix’s icons 4.5:1, and --fp-text-subtle moves from neutral step 10 to 11. The matrix’s text tiers and the black-or-white -contrast tokens reach 7:1 wherever black or white can; on mid-tone steps neither can, and they keep the better of the two (at least 4.5:1).
contrastAlgorithm"apca" | "wcag2""apca"How the black-or-white --fp-{role}-{n}-contrast tokens are picked. apca: white whenever white reaches 4.55:1 (the 4.5:1 floor plus 0.05 of head-room for 8-bit rounding; 7.05:1 under AAA), else the better of the two. wcag2: the higher of the two as measured before 8-bit rounding, so on a colour where black and white come within 0.01 of each other the painted pick can be the lower by less than 0.01. The contrast matrix is unaffected.
schemes"both" | "light" | "dark""both"Which colour schemes the CSS carries. both ships every colour as a light-dark() pair that follows the OS preference or [data-theme]. light or dark ships that scheme alone: no light-dark(), no [data-theme] rules, and a smaller file (72 KB instead of 97 KB for the full stylesheet of the theme @flexpixels/ui ships). A one-scheme build gives fp-theme-switch and dark islands nothing to switch to. Replaces the old settings.mode, which is now an error.

See Contrast for what the two contrast settings change.

seeds

jsonc
{
  "seeds": {
    "primary": "#4f46e5",
    "secondary": "#c026d3",
    "neutral": "#94a3b8",
    "success": null,
    "danger": null,
    "warning": null,
    "info": null,
  },
}

These are the defaults. Each seed is a hex colour with a #: 3 or 6 digits, or an opaque #rgbf / #rrggbbff. primary, secondary and neutral always have a value; the four semantic roles are generated at fixed hues (success: 145°, danger: 25°, warning: 85°, info: 250°) when set to null or omitted.

A seed you set is step 9. For primary, secondary and any semantic role you give a hex, step 9 of that role is the seed exactly, in both schemes, and is also emitted as --fp-{role}-seed. Step 10 is its hover. neutral and generated roles stay on the ramp.

surface (optional): the page colour of each scheme, as { "light": hex, "dark": hex } with either or both, plus an optional "spread". In its scheme, neutral step 1 is exactly the colour; the other scheme is unaffected. "spread": "surfaces" (the default) keeps the page’s tint on all five surface tokens (steps 1–5) and fades it out over steps 6–8; "spread": "page" tints only the page and blends steps 2–5 back to the neutral ramp by step 6. Use it for a deliberately tinted ground (warm paper in light mode, a deep navy #0F172A in dark mode). Page text, role text and control borders are re-solved against the anchored surfaces. A light anchor darker than OKLCH L 0.85 triggers SURFACE_ANCHOR_TOO_DARK; a dark anchor lighter than L 0.30 triggers SURFACE_ANCHOR_TOO_LIGHT.

Neutral hue tinting: when neutral’s chroma is below 0.05, the engine inherits primary’s hue so grays feel on-brand. Pass a neutral with chroma ≥ 0.05 to keep it independent.

Why no lightness control? Apart from step 9 and 10, every step takes only the hue and chroma of its seed. The 12-step OKLCH lightness ramp is shared by every role (CHROMA_LIGHTNESS_RAMP_LIGHT/DARK), so step meanings and contrast pairs hold across roles. To make a whole ramp more or less colourful, change the seed’s chroma. See OKLCH.

vision

jsonc
{
  "vision": {
    "variants": [],
    "attribute": "data-vision",
    "autoHighContrast": true,
    "output": "inline",
  },
}
FieldTypeDefaultNotes
variantsarray of "red-green" | "blue-yellow" | "monochrome" | "high-contrast"[]Extra palettes generated beside yours, each kind at most once. Your seeds are not changed; each variant is a set of seeds the engine regenerates.
attributedata-* attribute name"data-vision"The attribute on <html> that selects a variant, as in data-vision="red-green". fp-vision-switch sets it.
autoHighContrastbooleantrueWith "high-contrast" in variants, also apply it when the OS asks for more contrast (prefers-contrast: more) and the page has not picked a variant.
output"inline" | "separate""inline"inline writes the variants into theme.css. separate leaves their palettes out of theme.css (it only lists them in --fp-vision-variants); generateVisionCSS(config) returns one stylesheet per variant.

See Vision variants.

spacing

jsonc
{
  "spacing": { "mode": "hybrid", "base": 4 },
}
FieldTypeDefaultNotes
mode"linear" | "geometric" | "hybrid""hybrid"Multipliers of base for s-1..s-12. Linear: even increments. Geometric: roughly doubles every two steps. Hybrid: linear at the small end, geometric at the large end.
basenumber (px), above 04Maps to --fp-spacing-base. Outputs as precomputed rem.
scalenumber[] (whole px)mode defaultCustom primitive scale for --fp-dim-*. It replaces the generated scale entirely, so include every value components use (for example 20, 96 and 128).

radius

jsonc
{
  "radius": { "base": 4, "scale": [2, 4, 6, 8, 12, 16], "cornerShape": "round" },
}
FieldTypeDefaultNotes
basenumber (px)4--fp-radius-base is the scale step nearest this value (the smaller one on a tie), so 5 gives --fp-radius-2 (4px).
scalenumber[][2, 4, 6, 8, 12, 16]Primitive ladder (--fp-radius-1..N), smallest first. The engine also emits --fp-radius-full: 9999px and the semantic --fp-corner-{control,surface,overlay,circle}.
cornerShape"round" | "squircle" | "bevel" | "scoop" | "notch" | "square""round"Emitted as --fp-corner-shape for the CSS corner-shape property. Browsers without it show ordinary rounded corners.
corners{ control?, surface?, overlay? } in px; control also takes "full"derivedThe semantic corners, stated. By default --fp-corner-control is base, --fp-corner-surface the step nearest base × 2 and --fp-corner-overlay the step nearest base × 3. Set one when the design is not that ladder: pill controls (control: "full") with 24px cards (surface: 24), or rounded controls on square surfaces (surface: 0). Only control takes "full": a surface is as tall as its content, so it has no pill.

border

jsonc
{
  "border": {
    "base": 1,
    "scale": [1, 2, 3, 4],
    "glowEnabled": true,
    "animatedEnabled": false,
    "gradient": { "preset": "none", "angle": 135 },
  },
}
FieldTypeDefaultNotes
basenumber (px)1--fp-border-base is the scale step equal to this value, or this width itself when no step matches.
scalenumber[][1, 2, 3, 4]Primitive widths (--fp-border-1..N), smallest first.
widthScale{ hairline, thin, medium, thick }{1, 1.5, 2, 3}Named width overrides. Merged with defaults.
glowEnabledbooleantrueEmits --fp-glow-focus, --fp-glow-danger, etc.
animatedEnabledbooleanfalseOff by default (decorative motion). Opt in to emit beam / shimmer conic-gradient tokens.
gradient.preset"none" | "primary-secondary" | "primary-neutral" | "secondary-neutral""none"Seed-derived gradient preset.
gradient.anglenumber 0–360135Gradient angle in degrees.
gradient.customstring—Override the preset with a raw CSS gradient.

elevation

jsonc
{
  "elevation": {
    "style": "auto",
    "shadowIntensity": 0.12,
    "shadowIntensityDark": 0.4,
    "tintChroma": 0.01,
    "neumorphicDepth": 0.1,
    "backdropBlur": 12,
    "glassOpacity": 0.7,
    "glass": "frosted",
    "brutalismOffset": 4,
    "levelAliases": { "rest": 1, "lifted": 2, "overlay": 3, "modal": 4 },
    "surfaceAware": false,
  },
}
FieldTypeDefaultNotes
style"auto" | "flat" | "neumorphic" | "liquid-glass" | "brutalism""auto"Shadow model. auto behaves like flat unless scenario picks another.
shadowIntensitynumber 0–10.12Shadow tint opacity in light mode. Ignored by neumorphic and brutalism.
shadowIntensityDarknumber 0–10.4Shadow tint opacity in dark mode, where a light-mode value would be invisible.
tintChromanumber 0–0.050.01Chroma of the shadow tint. 0 is grey.
tintGradient{ angle?: 0–360, source?: "neutral" | "primary" }unsetTurns the flat tonal lift of raised surfaces into a gradient from the lit edge.
neumorphicDepthnumber 0–0.30.1Lightness delta for the neumorphic dual shadows.
backdropBlurnumber 0–64 (px)12Liquid-glass blur radius.
glassOpacitynumber 0–10.7Liquid-glass surface opacity. With glass: "frosted" it must be at least 0.4, whatever style is.
glass"frosted" | "clear""frosted"frosted keeps text at AA on the glass; clear is more see-through and gives that up.
glownumber 0–31 under liquid-glass, else offTheme glow, emitted as --fp-glow-size.
ambientup to 4 { role, x, y, size?, strength? }unsetColoured radial light on the page surface, emitted as --fp-surface-app-image.
brutalismOffsetnumber 2–20 (px)4Base offset for brutalism hard shadows.
levelAliasesRecord<string, 1–4>{ rest:1, lifted:2, overlay:3, modal:4 }Semantic names for levels. Each alias emits as --fp-elevation-{alias}. A name cannot be a bare number ("2" is level 2 itself).
scales.neumorphic{ offsetSteps?, blurMultiplier }blurMultiplier: 2Per-level neumorphic offsets (default [3, 5, 8, 12], four values) and blur multiplier.
scales.brutalism{ offsetMultipliers }[1, 1.5, 2, 3]Per-level multipliers applied to brutalismOffset.
levelMetadataRecord<string, { intent?, whenToUse?, whenNotToUse?, examples?, pairsWith? }>engine defaultsPer-level guidance, served by the MCP resource flexpixels://elevation/levels/{key} and the DTCG export.
surfaceAwarebooleanfalseEmits per-context shadow variants --fp-elevation-{level}-on-{app,subtle,ghost,image} (flat and liquid-glass).
perceptual.contrastFloornumber 0–1unsetOpt-in: any perceptual object, under flat or liquid-glass, emits --fp-elevation-{n}-perceived-depth and -contrast-on-app-light / -dark. contrastFloor itself is not read yet.
scenario"marketing" | "app" | "editorial" | "dashboard"unsetA curated bundle applied before your own fields, which win. Same names as typography.scenario.

interaction

jsonc
{
  "interaction": {
    "opacityDisabled": 0.5,
    "durations": { "xfast": 75, "fast": 100, "normal": 150, "slow": 250, "xslow": 400 },
    "animationDurations": { "enter": 400, "loopFast": 1000, "loop": 1500, "loopSlow": 2500 },
    "states": { "hover": 0.05, "press": 0.1, "drag": 0.14, "selected": 0.08 },
    "spring": { "stiffness": 220, "damping": 28, "mass": 1 },
    "stagger": { "delay": 50, "delayFast": 40, "delaySlow": 60 },
    "focusRing": { "width": 2, "offset": 2, "color": "primary" },
    "scaleActive": 0.98,
  },
}
FieldTypeDefaultNotes
opacityDisablednumber 0–10.5--fp-opacity-disabled.
durations{ xfast, fast, normal, slow, xslow } (ms)75 / 100 / 150 / 250 / 400--fp-transition-duration-{name}; --fp-transition-duration is normal.
animationDurations{ enter, loopFast, loop, loopSlow } (ms)400 / 1000 / 1500 / 2500--fp-animation-duration-{enter,loop-fast,loop,loop-slow}.
easingsRecord<string, [x1, y1, x2, y2]>built-in setExtra or replacement cubic-bezier curves, emitted as --fp-transition-easing-{name}.
states{ hover, press, drag, selected } 0–10.05 / 0.1 / 0.14 / 0.08State-layer opacities, --fp-state-{name}.
spring{ stiffness, damping, mass }220 / 28 / 1--fp-spring-*, read by spring-driven motion. Must settle within 5 seconds.
stagger{ delay, delayFast, delaySlow } (ms)50 / 40 / 60Per-item delays for staggered entrances, --fp-stagger-delay*.
focusRing.width / offsetnumber (px)2 / 2--fp-focus-ring-width, --fp-focus-ring-offset.
focusRing.colora colour role"primary"--fp-focus-ring-color is that role’s --fp-{role}-text, the shade measured to show against the page.
scaleActivenumber above 0, up to 10.98--fp-scale-active, the press-in scale.

Reduced motion is not a duration any more: the motion switches (--fp-transitions, --fp-animations) and the OS preference handle it. An old config’s durations.reduced is accepted and ignored.

layout

jsonc
{
  "layout": {
    "breakpoints": { "xs": 320, "sm": 640, "md": 768, "lg": 1024, "xl": 1280, "2xl": 1920 },
    "columns": 12,
    "gutter": "s-6",
    "section": {
      "paddingX": "s-8",
      "paddingY": "s-10",
      "paddingXCompact": "s-7",
      "paddingYCompact": "s-9",
      "gap": "s-9",
    },
    "stack": { "gap": "s-4" },
    "gaps": { "xs": "s-1", "sm": "s-3", "md": "s-4", "lg": "s-6", "xl": "s-8" },
  },
}
FieldTypeDefaultNotes
breakpointsRecord<string, number>xs..2xlEmitted as --fp-bp-{name}. Replaces the default set: list every breakpoint you want.
containerMaxWidthsRecord<string, number>per-breakpointEach key must name a breakpoint; a breakpoint without one gets its own width.
columnsnumber12Grid column count.
gutter"s-1".."s-12""s-6"Semantic spacing step the grid gutter aliases to.
section.*"s-1".."s-12"s-8/10/7/9/9Default + compact section padding and the section-to-section gap.
stack.gap"s-1".."s-12""s-4"Default stack gap step.
gaps.{xs..xl}"s-1".."s-12"s-1/3/4/6/8The layout primitives’ gap="…" steps: --fp-layout-gap-{step}.

scroll

jsonc
{
  "scroll": {
    "width": "thin",
    "track": { "bg": "{neutral.2}" },
    "thumb": { "bg": "{neutral.7}", "hover": "{neutral.8}", "radius": 4 },
  },
}
FieldTypeDefaultNotes
width"thin" | "auto" | "none""thin"CSS scrollbar-width keyword.
track.bg / thumb.bg / thumb.hovertoken alias or CSS colorneutral stepsStrings like "{neutral.2}" resolve to var(--fp-neutral-2). Anything else is an error.
thumb.radiusnumber (px)4Thumb border-radius.

inset

jsonc
{ "inset": { "factor": "tight" } }
FieldTypeDefaultNotes
factornumber 0–1 or "tight" | "balanced" | "generous""tight"The least padding a component keeps from its own corner: --fp-inset-{role} = max(0, corner × factor − stroke). tight = 0.2929 (1 − 1/√2, the geometric minimum), balanced = 0.5, generous = 1.0 (the whole radius).

sizes

The size axis: what size="sm" | "md" | "lg" means for every component. Each tier is a set of dimensions, emitted as --fp-size-{tier}-{dim}; md is also the default --fp-size-{dim}.

FieldTypesmmdlgNotes
insetInlinestep 1–12567Inline padding, as a step of --fp-s-*.
insetBlockstep 1–12345Block padding.
gapstep 1–12223Gap between an icon and its label.
fonttext rolelabelbodybody-lgType role for control text.
titleFonttext rolebody-lgtitleheadlineType role for a surface’s title.
titleLineHeighttext roletitle——Role whose line height the title takes, if not titleFont’s.
icon"sm" | "md" | "lg"smmdlgIcon size.
boxnumber (px)243240Size of an avatar, swatch or thumb.
minTargetnumber (px)364452Minimum hit area; raised to the touch-target size under a coarse pointer.

There is also a private xs tier that only the compact set (--fp-size-compact-*) reads. Font roles must name a text role that exists.

output

jsonc
{
  "output": { "tokens": "lean", "contrastMatrix": false, "legacyFallback": false },
}
FieldTypeDefaultNotes
tokens"lean" | "full""lean"What generateThemeCSS writes. lean: the tokens components read, the public tier, the colour ramps with their alphas and seeds, the type roles, the size axis and the global knobs. full: every token the engine computes.
contrastMatrixbooleanfalseAdds the APCA matrix (-on-text, -on-text-soft, -on-icon) and -contrast on every step to a lean stylesheet.
legacyFallbackbooleanfalseAdds static fallbacks for engines without light-dark(), relative colours and round() (roughly Chrome before 125, Safari before 18, Firefox before 128): every colour again as rgb() under @supports not, per scheme, and the snapped lengths unwrapped; the forced-colours, more-contrast and less-transparency overrides are stated again after them, so an old engine still honours those preferences. The exports (DTCG, DESIGN.md) state the same values either way. Off, the stylesheet is modern-only (42% smaller for the full stylesheet of the theme @flexpixels/ui ships, 28% for the default one), and those engines resolve no colour token.

output only trims the CSS. generateFullThemeCSS, the DTCG export, DESIGN.md and the MCP tools always see every token. See Build & Import.

dataviz

jsonc
{
  "dataviz": {
    "categoricalCount": 12,
    "sequentialRole": "primary",
    "divergingStart": "danger",
    "divergingEnd": "info",
  },
}
FieldTypeDefaultNotes
categoricalCountwhole number 3–1212How many series colours: --fp-chart-cat-{1..N}.
sequentialRolea colour role"primary"Hue of the 9-step sequential ramp, --fp-chart-seq-{1..9}.
divergingStarta colour role"danger"Negative end of the 9-step diverging ramp, --fp-chart-div-1.
divergingEnda colour role"info"Positive end, --fp-chart-div-9.

Every chart colour has a -contrast child for labels on it. The chart palette is in the full stylesheet, not the lean one.

typography

The largest section. See the Typography System page for the rationale, the Custom Themes guide for reference tables, and the schema for every field:

  • base — must be 16.
  • strictGrid (default true) — sizes and line heights must be even, on a 2px grid.
  • lineHeightFormula — "ratio-1.5" (default), "golden" or "compact".
  • fluid — { minViewport: 320, maxViewport: 1280, roles? } by default, or false. maxViewport must be above minViewport, and each of roles must name a text role that exists.
  • scale — font sizes in px, smallest first, default [12, 14, 16, 18, 20, 24, 32, 40]; lineHeights — optional explicit line heights, null entries use the formula.
  • fontFamilies.{display, body, mono}, fontWeights.{regular, medium, semibold, bold} (each 1–1000; no other names), letterSpacings (each a length in em, rem or px, 0 or normal).
  • metrics.{display, body, mono} — font metrics per family slot, in the font’s own units; they produce --fp-text-{role}-trim-top and -trim-bottom. A slot you set needs all seven fields: familyName (string), unitsPerEm (above 0), ascent, descent, lineGap, capHeight (not above ascent) and xHeight.
  • comfort.{lineLength, minSize, maxLineHeightRatio} — emitted as --fp-text-comfort-* (defaults 65ch, 1rem, 1.6; lineLength and minSize must be CSS lengths, so "70" is an error); the fp-prose component reads them.
  • variableAxes.{wght, opsz, slnt} — variable-font axis triples [min, max, default].
  • scenario — "marketing" | "app" | "editorial" | "dashboard", a curated bundle applied before your own fields.
  • typeStyles — per-role definitions and overrides. An entry replaces the role whole: give fontSizeStep, lineHeightStep and fontWeight (start from getResolvedTypeStyle(config.typography, role) to change one field of a built-in role). Each role takes fontSizeStep, lineHeightStep, lineHeightRatio, fontWeight, letterSpacing, fontFamily, fontStyle, textTransform, textDecoration, fontVariantNumeric, optical, weightAxis, fluid, and the guidance fields intent, whenToUse, whenNotToUse, examples, minViewportWidth.

Validation

The same Zod schema, ThemeConfigSchema, checks every config. Quick recipes:

ts
import { ThemeConfigSchema, mergeThemeConfig } from "@flexpixels/cortex";

// Merge over the defaults and validate; throws a ZodError on invalid input
const config = mergeThemeConfig(userInput);

// Or collect field-level errors without throwing (needs at least the three brand seeds; scenario bundles are not applied)
const result = ThemeConfigSchema.safeParse(userInput);
if (!result.success) {
  console.error(result.error.issues);
}

See Validators for what validation checks, and the difference between validateThemeConfig, mergeThemeConfig and mergeWithDefaults.