Token API Reference
The families of CSS custom properties the Cortex engine generates, with their names and default values.
This page lists the main token families @flexpixels/cortex generates as CSS custom properties. Defaults are for the engine’s default config. The default stylesheet (generateThemeCSS, the lean theme) leaves some tokens out; they are marked (full stylesheet only) and are in the full stylesheet (generateFullThemeCSS, or output.tokens: "full"). The marks are for the theme @flexpixels/ui ships. For an exhaustive list of what a given theme declares, use the MCP tools get_tokens / search_tokens with tier: "all", or read the generated CSS.
All tokens use the configured prefix (default fp), so --fp-primary-9 becomes --{prefix}-primary-9 if you change the prefix.
Component override variables (fallbacks)
Library components (e.g. fp-button, fp-tag, fp-switch) read their colours and sizes through CSS custom properties with a fallback, and the fallbacks resolve to design tokens:
- Pattern:
var(--fp-<component>-<property>, <default>), where the default is a token or a private variable built from tokens. - Example:
--_bg: var(--fp-button-background, var(--_v-bg))—fp-buttonuses--fp-button-backgroundwhen it is set, else the colour itsvariantandintentpick (for a solid primary button,--fp-primary-9).
End users can override any hook on the host (or an ancestor) to customize a single instance or a whole section. Per-component hook lists are in each component’s docs and via the components_get_css_hooks tool of the full FlexPixels MCP server, @flexpixels/mcp (not yet published; the Cortex server, @flexpixels/cortex-mcp, does not have it).
Color Tokens
For each role (primary, secondary, neutral, success, danger, warning, info), the engine generates a 12-step scale from H+C seeds, a lightness ramp (a fixed lightness per step, inlined into each token), and a chroma curve (--fp-C-1 … --fp-C-12). Light/dark mode is handled by light-dark() plus [data-theme="light"] / [data-theme="dark"] attribute rules (the engine never emits class selectors). For a role with a configured seed, step 9 is the seed itself and step 10 its hover.
12-Step Scale
| Token | Step | Usage |
|---|---|---|
--fp-{role}-1 | 1 | App background (page canvas) |
--fp-{role}-2 | 2 | Subtle background (sidebars, cards) |
--fp-{role}-3 | 3 | UI element background (inputs, normal state) |
--fp-{role}-4 | 4 | Hover state |
--fp-{role}-5 | 5 | Active/selected (pressed state) |
--fp-{role}-6 | 6 | Subtle border (separators) |
--fp-{role}-7 | 7 | Strong border (focus rings, inputs) |
--fp-{role}-8 | 8 | Interactive object (icons, links) |
--fp-{role}-9 | 9 | Solid surface (buttons, badges) |
--fp-{role}-10 | 10 | Solid hover (button hover) |
--fp-{role}-11 | 11 | Low-contrast text (secondary copy) |
--fp-{role}-12 | 12 | High-contrast text (headings) |
Contrast Pairs (Binary)
Every step has a -contrast token in the full stylesheet — a build-time, measured black/white foreground:
| Token | Description |
|---|---|
--fp-{role}-{n}-contrast | light-dark(black/white, black/white) — picked by measured luminance to meet WCAG 2.1 AA (by default: white while it clears 4.5:1, else black) |
Use --fp-primary-9-contrast as the text colour whenever --fp-primary-9 is the background. It meets WCAG AA on that surface in both light and dark mode, and resolves via color-scheme. The default stylesheet has -contrast for steps 8 to 11; the full stylesheet has it for every step.
APCA Contrast Matrix (Tinted)
Every step also generates three APCA-computed tinted foreground tokens using real apca-w3 Lc calculation at build time:
| Token | APCA Lc | Description |
|---|---|---|
--fp-{role}-{n}-on-text | ≥ 90 | Body text — tinted foreground from same color scale |
--fp-{role}-{n}-on-text-soft | ≥ 60 | Large or secondary text — softer contrast |
--fp-{role}-{n}-on-icon | ≥ 45 | Icons, decorative elements — minimum contrast |
The matrix is in the full stylesheet only (generateFullThemeCSS, or output.tokens: "full"), or in a lean one built with output.contrastMatrix: true. See Build & Import.
These tokens use steps of the same role, so foregrounds stay on-brand. Each also has to clear a WCAG 2.x floor (4.5:1 for the text tiers, 3:1 for icons). When no same-scale step reaches the target, the token falls back to pure black or white. Light and dark are solved separately and combined with light-dark().
/* Needs the contrast matrix: theme-full.css, or output.contrastMatrix: true. */
/* Use on-text for tinted foreground on solid button */
background: var(--fp-primary-9);
color: var(--fp-primary-9-on-text);
/* Use on-icon for an icon on a danger surface */
background: var(--fp-danger-3);
fill: var(--fp-danger-3-on-icon);Seeds and per-role colours
| Token | Description |
|---|---|
--fp-{role}-h | Hue (0–360) of the role’s ramp. |
--fp-{role}-c | Chroma (0–0.37) of the role’s ramp. |
--fp-{role}-seed | The configured hex (brand roles only). Step 9 reads it. |
--fp-{role}-text | The role’s colour as text on the page, measured to 4.5:1 against neutral steps 1–3. |
--fp-{role}-border | Step 8, adjusted to reach 3:1 against the page — a control’s outline. |
--fp-C-{1..12} | The chroma curve multipliers shared by every role (raised for steps 7, 8 and 10 on P3 displays). |
Config uses hex; the engine converts to H and C at build. Changing --fp-{role}-h or -c at runtime re-tints the ramp steps; step 9, its hover and the alpha stops follow --fp-{role}-seed. The -contrast, -text and -border values are measured at build time and do not change with them.
Surface semantics
The neutral roles components paint with:
| Token | Resolves to | Use |
|---|---|---|
--fp-surface-app | --fp-neutral-1 | The page, the outermost layer |
--fp-surface-subtle | --fp-neutral-2 | A recessed region: sidebar, well, section band |
--fp-surface-element | --fp-neutral-3 | A raised element: card, panel, tile |
--fp-surface-hover | --fp-neutral-4 | Hover background |
--fp-surface-active | --fp-neutral-5 | Active/pressed background |
--fp-surface-overlay | --fp-neutral-1 light, --fp-neutral-3 dark | Menus, popovers, dialogs |
--fp-surface-inverse | the other scheme’s page | Tooltips, toasts |
--fp-border-subtle-color | --fp-neutral-6 | Subtle border |
--fp-border-strong-color | --fp-neutral-border | A control’s boundary (3:1) |
--fp-text-subtle | --fp-neutral-10 | Tertiary text |
--fp-text-muted | --fp-neutral-11 | Secondary text |
--fp-text-quiet | between 11 and 12 | Lead-ins, descriptions |
--fp-text-default | --fp-neutral-12 | Default text |
--fp-text-inverse | the other scheme’s default text | Text on --fp-surface-inverse |
Static colors
| Token | Description |
|---|---|
--fp-white-a{1..12} | White at 12 opacity levels (from 2% to 98%) |
--fp-black-a{1..12} | Black at 12 opacity levels (from 2% to 98%) |
These do not change between light and dark mode.
Alpha Stops (Per Role)
Each dynamic role gets 5 translucent tints from step 9 (with its lightness held where the paired text would otherwise fall under 4.5:1):
| Token | Opacity | Use Case |
|---|---|---|
--fp-{role}-a1 | 5% | Ghost hover |
--fp-{role}-a2 | 10% | Subtle tint |
--fp-{role}-a3 | 20% | Active press |
--fp-{role}-a4 | 30% | Focus ring |
--fp-{role}-a5 | 45% | Badge / chip |
Spacing Tokens
Three-layer architecture: Primitives -> DNA -> Semantics.
Primitives (--fp-dim-*)
Precomputed rem values (px / 16). Default scale (spacing.mode: "hybrid"):
| Token | Value | Pixels (at 16px root) |
|---|---|---|
--fp-dim-2 | 0.125rem | 2px (full stylesheet only) |
--fp-dim-4 | 0.25rem | 4px |
--fp-dim-6 | 0.375rem | 6px (full stylesheet only) |
--fp-dim-8 | 0.5rem | 8px |
--fp-dim-10 | 0.625rem | 10px (full stylesheet only) |
--fp-dim-12 | 0.75rem | 12px |
--fp-dim-16 | 1rem | 16px (full stylesheet only) |
--fp-dim-20 | 1.25rem | 20px |
--fp-dim-24 | 1.5rem | 24px |
--fp-dim-32 | 2rem | 32px (full stylesheet only) |
--fp-dim-40 | 2.5rem | 40px |
--fp-dim-48 | 3rem | 48px (full stylesheet only) |
--fp-dim-64 | 4rem | 64px (full stylesheet only) |
--fp-dim-80 | 5rem | 80px |
--fp-dim-96 | 6rem | 96px (full stylesheet only) |
--fp-dim-128 | 8rem | 128px |
DNA (--fp-spacing-*)
| Token | Value | Description |
|---|---|---|
--fp-spacing-base | var(--fp-dim-{base}) | Configured base unit (full stylesheet only) |
Semantic (--fp-s-*) — use these
Each step is calc(<rem> * var(--fp-density, 1)), snapped to whole pixels with round(). Multipliers below are for the default hybrid mode.
| Token | Multiplier | Pixels (base=4) | Description |
|---|---|---|---|
--fp-s-1 | 0.5× | 2px | Tightest (icon gaps) |
--fp-s-2 | 1× | 4px | Base unit (inline padding) |
--fp-s-3 | 1.5× | 6px | Small gap |
--fp-s-4 | 2× | 8px | Standard padding |
--fp-s-5 | 3× | 12px | Medium gap |
--fp-s-6 | 4× | 16px | Section padding |
--fp-s-7 | 6× | 24px | Large gap |
--fp-s-8 | 8× | 32px | Section margin |
--fp-s-9 | 12× | 48px | Page section |
--fp-s-10 | 16× | 64px | Large section |
--fp-s-11 | 24× | 96px | Hero section |
--fp-s-12 | 32× | 128px | Maximum spacing |
The spacing roles --fp-gap-{inline,actions,items,header,sections,divider} point at steps of this scale; see Spacing.
Border Tokens
Three-layer architecture for border widths plus gradient support.
Primitives (--fp-border-*)
| Token | Default Value | Description |
|---|---|---|
--fp-border-none | 0 | No border (full stylesheet only) |
--fp-border-1 | 1px | 1px width (px, not rem — font-independent) |
--fp-border-2 | 2px | 2px width |
--fp-border-3 | 3px | 3px width (full stylesheet only) |
--fp-border-4 | 4px | 4px width (full stylesheet only) |
--fp-border-base | var(--fp-border-1) | Configured base width |
--fp-border-w-hairline | 1px | Named width |
--fp-border-w-thin | 1.5px | Named width (full stylesheet only) |
--fp-border-w-medium | 2px | Named width |
--fp-border-w-thick | 3px | Named width |
--fp-border-gradient-brand | CSS gradient | Primary → secondary |
--fp-border-gradient-subtle | CSS gradient | Neutral → primary → neutral |
--fp-border-gradient-active | CSS gradient | Only when border.gradient.preset or .custom is set |
Semantic (--fp-stroke-*) — use these
| Token | Value | Description |
|---|---|---|
--fp-stroke-hairline | var(--fp-border-w-hairline) | Thinnest borders |
--fp-stroke-control | var(--fp-border-base) | Buttons, inputs, interactive controls |
--fp-stroke-divider | var(--fp-border-w-hairline) | Separators, table borders |
--fp-stroke-strong | var(--fp-border-w-medium) | Emphasized borders |
--fp-stroke-accent | var(--fp-border-w-thick) | Decorative accent borders |
--fp-border-semantic-* shorthands (width, style and colour in one) are listed on the Shape page.
Radius Tokens
Three-layer architecture for border radius.
Primitives (--fp-radius-*)
| Token | Default Value | Description |
|---|---|---|
--fp-radius-1 | 0.125rem | Smallest radius |
--fp-radius-2 | 0.25rem | Small radius |
--fp-radius-3 | 0.375rem | Medium radius (full stylesheet only) |
--fp-radius-4 | 0.5rem | Large radius |
--fp-radius-5 | 0.75rem | Extra large radius |
--fp-radius-6 | 1rem | Maximum radius |
--fp-radius-full | 9999px | Full circle |
--fp-radius-base | var(--fp-radius-2) | Configured base (default 4px) |
The default stylesheet keeps the radius steps the corner tokens and components read, so which steps are full-only depends on the config. With the defaults above, --fp-radius-3 and --fp-radius-6 are; in the theme @flexpixels/ui ships (base 8px, seven steps), --fp-radius-3 and --fp-radius-5 are.
Semantic (--fp-corner-*) — use these
| Token | Value | Description |
|---|---|---|
--fp-corner-control | var(--fp-radius-base) | Buttons, inputs |
--fp-corner-surface | var(--fp-radius-4) | Cards (8px) |
--fp-corner-overlay | var(--fp-radius-5) | Modals, overlays (12px) |
--fp-corner-circle | var(--fp-radius-full) | Avatars, full-circle elements |
--fp-corner-shape | round | Corner character (radius.cornerShape) |
By default --fp-corner-control is the base radius, --fp-corner-surface the step nearest base × 2 and --fp-corner-overlay the step nearest base × 3. radius.corners states any of them instead, in px (control also takes "full"): { "control": "full", "surface": 24 } gives pill controls with 24px cards.
Elevation Tokens
Shadow DNA
| Token | Description |
|---|---|
--fp-shadow-tint | Shadow colour: tinted from neutral-9 in light mode, near-black in dark mode (light-dark()) |
Neumorphic themes use --fp-shadow-light / --fp-shadow-dark instead, and brutalism --fp-shadow-hard.
Elevation Levels
| Token | Description |
|---|---|
--fp-elevation-1 | Single drop shadow (subtle) |
--fp-elevation-2 | Double drop shadow (raised) |
--fp-elevation-3 | Double drop shadow (floating) |
--fp-elevation-4 | Double drop shadow (overlay) |
The aliases --fp-elevation-rest, -lifted, -overlay and -modal point at levels 1–4. Values above are for the default flat style.
Surface Tinting
| Token | Description |
|---|---|
--fp-surface-tint-1 | none (full stylesheet only) |
--fp-surface-tint-2 | 3% neutral overlay (light) / 5% white (dark) |
--fp-surface-tint-3 | 5% neutral overlay (light) / 8% white (dark) |
--fp-surface-tint-4 | 7% neutral overlay (light) / 12% white (dark) (full stylesheet only) |
Typography Tokens
Font Size + Line Height Primitives
Indexed 1..N from the configured scale. The default stylesheet keeps only the steps that other tokens or components use; the full stylesheet has every step. The table below reflects this site’s config:
| Step | Size | Line height | Ratio | CSS variable |
|---|---|---|---|---|
| 1 | 12px (0.75rem) | 18px (1.125rem) | 150% | var(--fp-font-size-1) |
| 2 | 14px (0.875rem) | 22px (1.375rem) | 157% | var(--fp-font-size-2) |
| 3 | 16px (1rem) | 24px (1.5rem) | 150% | var(--fp-font-size-3) |
| 4 | 18px (1.125rem) | 28px (1.75rem) | 156% | var(--fp-font-size-4) |
| 5 | 20px (1.25rem) | 30px (1.875rem) | 150% | var(--fp-font-size-5) |
| 6 | 24px (1.5rem) | 36px (2.25rem) | 150% | var(--fp-font-size-6) |
| 7 | 32px (2rem) | 48px (3rem) | 150% | var(--fp-font-size-7) |
| 8 | 40px (2.5rem) | 60px (3.75rem) | 150% | var(--fp-font-size-8) |
| 9 | 48px (3rem) | 72px (4.5rem) | 150% | var(--fp-font-size-9) |
| 10 | 56px (3.5rem) | 84px (5.25rem) | 150% | var(--fp-font-size-10) |
| 11 | 64px (4rem) | 96px (6rem) | 150% | var(--fp-font-size-11) |
Line-height formulas
Auto-computed line heights use one of three formulas, chosen via typography.lineHeightFormula:
| Formula key | Multiplier | Label | Best for |
|---|---|---|---|
ratio-1.5 | 1.5× | 1.5× ratio snapped to 2px grid | UI (default). Predictable rhythm for forms, cards, dashboards. |
golden | 1.618× | Golden ratio (1.618×) snapped to 2px grid | Editorial / long-form reading. |
compact | 1.3× | Compact 1.3× ratio snapped to 2px grid | Data-dense dashboards and tables. |
Semantic line-height aliases: --fp-line-height-flat (1), --fp-line-height-tight (step 1), --fp-line-height-snug (step 2), --fp-line-height-normal (step 3), --fp-line-height-relaxed (step 4).
Semantic Text Roles (--fp-text-{role}-*)
Each role bundles font-size, line-height, font-weight, letter-spacing, family, and (when metrics are available) leading trim. The built-in roles (a theme’s typography.typeStyles can add more; this site’s theme adds four — see Typography):
| Role | Family | Size step | Weight | Intent |
|---|---|---|---|---|
caption | body | 1 | regular | Smallest readable text — secondary metadata that supports primary content. |
label | body | 2 | medium | Form-field and UI labels — short, scannable, slightly emphasized. |
body | body | 3 | regular | Primary reading text for long-form content and the default UI body copy. |
body-lg | body | 4 | regular | Slightly larger reading text — used for emphasis without crossing into title. |
title | display | 5 | semibold | Section title — the dominant heading inside a card, modal, or content block. |
headline | display | 6 | semibold | Page-level headline — typically the h1 inside an app screen or content view. |
display | display | 8 | bold | Largest display text — used sparingly for marketing impact. |
button | body | 2 | semibold | Text rendered inside interactive buttons — short, decisive, slightly emphasized. |
input | body | 3 | regular | Text typed into form inputs — matches body for visual continuity. |
helper | body | 1 | regular | Microcopy under form fields — explanations, validation hints, character counts. |
code | mono | 2 | regular | Inline code, keyboard keys, and fixed-width tokens embedded in prose. |
link | body | 3 | medium | Inline hyperlink text — slightly emphasized and underlined for affordance. |
quote | body | 4 | regular | Pull-quotes, blockquotes, and testimonial body — larger reading text that stays upright. |
data | body | 6 | semibold | Large numeric / metric display — KPIs, stat values, big figures with aligned digits. |
Read flexpixels://typography/roles/{role} from the Cortex MCP server for full
whenToUse / whenNotToUse / examples per role.
Font Family slots
| Token | Slot |
|---|---|
--fp-font-family-display | Headlines, hero copy, eyebrow |
--fp-font-family-body | Paragraphs, UI text (default for most roles) |
--fp-font-family-mono | Code, data, ASCII art |
See Typography for the rest: fluid sizes, leading trim, reading-comfort tokens, variable-font axes, scenario presets and the MCP tools.
Global & Interaction Tokens
Tokens for motion, focus and the global scale axes. The full interaction set (easings, state layers, spring, stagger) is on the Interaction page.
Motion & Interaction
| Token | Purpose |
|---|---|
--fp-opacity-disabled | Global opacity for disabled elements |
--fp-transition-duration-xfast | Extra-fast transition (default 75ms) (full stylesheet only) |
--fp-transition-duration-fast | Fast transition (default 100ms) |
--fp-transition-duration-normal | Normal transition (default 150ms) |
--fp-transition-duration-slow | Slow transition (default 250ms) |
--fp-transition-duration-xslow | Extra-slow transition (default 400ms) (full stylesheet only) |
--fp-transition-easing-ease-out | Default out easing curve |
--fp-transition-easing-ease-in-out | Default in-out easing curve |
--fp-transition-easing-linear | Linear easing |
--fp-focus-ring-width | Standard focus ring stroke width |
--fp-focus-ring-offset | Standard focus ring offset distance |
--fp-focus-ring-color | Focus ring colour (default var(--fp-primary-text)) |
--fp-scale-active | Active scale multiplier (e.g. 0.98) |
Global scale tokens
| Token | Default | Description |
|---|---|---|
--fp-density | 1 | Spacing density multiplier; set it (or data-density) on <html>. Presets --fp-density-{compact,default,relaxed} = 0.75 / 1 / 1.25. |
--fp-type-scale | 1 | Typographic scale multiplier; also drives the icon sizes below. |
--fp-icon-size-sm | calc(1rem * var(--fp-type-scale)) | 16px icon at default scale |
--fp-icon-size-md | calc(1.25rem * var(--fp-type-scale)) | 20px icon at default scale |
--fp-icon-size-lg | calc(1.5rem * var(--fp-type-scale)) | 24px icon at default scale |
--fp-contrast-threshold | 0.6 (AA) / 0.45 (AAA) | Legacy threshold (full stylesheet only). Binary -contrast is measured for WCAG 2.1 AA; tinted -on-text/-on-text-soft/-on-icon use real APCA Lc plus a WCAG floor. |
The size axis (--fp-size-*) is described on Size & Density, and layout tokens (--fp-bp-*, --fp-container-*, --fp-grid-*, --fp-layout-*) on Layout.
Precomputed Rem Values
Spacing, radius and type sizes are output as precomputed rem values (px / 16), with these exceptions: --fp-radius-full is 9999px, and fluid type roles are round(nearest, clamp(…), step) expressions mixing rem and vw. Border widths, focus-ring sizes, --fp-touch-target-* and the size axis’s --fp-size-*-min-target floors stay in px, so a hit area keeps its size whatever the root font size. No runtime conversion is needed — consume the tokens via var().
For example, --fp-dim-4: 0.25rem equals 4px at a 16px root font size and scales with browser zoom and the root font size.