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-button uses --fp-button-background when it is set, else the colour its variant and intent pick (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

TokenStepUsage
--fp-{role}-11App background (page canvas)
--fp-{role}-22Subtle background (sidebars, cards)
--fp-{role}-33UI element background (inputs, normal state)
--fp-{role}-44Hover state
--fp-{role}-55Active/selected (pressed state)
--fp-{role}-66Subtle border (separators)
--fp-{role}-77Strong border (focus rings, inputs)
--fp-{role}-88Interactive object (icons, links)
--fp-{role}-99Solid surface (buttons, badges)
--fp-{role}-1010Solid hover (button hover)
--fp-{role}-1111Low-contrast text (secondary copy)
--fp-{role}-1212High-contrast text (headings)

Contrast Pairs (Binary)

Every step has a -contrast token in the full stylesheet — a build-time, measured black/white foreground:

TokenDescription
--fp-{role}-{n}-contrastlight-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:

TokenAPCA LcDescription
--fp-{role}-{n}-on-text≥ 90Body text — tinted foreground from same color scale
--fp-{role}-{n}-on-text-soft≥ 60Large or secondary text — softer contrast
--fp-{role}-{n}-on-icon≥ 45Icons, 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().

css
/* 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

TokenDescription
--fp-{role}-hHue (0–360) of the role’s ramp.
--fp-{role}-cChroma (0–0.37) of the role’s ramp.
--fp-{role}-seedThe configured hex (brand roles only). Step 9 reads it.
--fp-{role}-textThe role’s colour as text on the page, measured to 4.5:1 against neutral steps 1–3.
--fp-{role}-borderStep 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:

TokenResolves toUse
--fp-surface-app--fp-neutral-1The page, the outermost layer
--fp-surface-subtle--fp-neutral-2A recessed region: sidebar, well, section band
--fp-surface-element--fp-neutral-3A raised element: card, panel, tile
--fp-surface-hover--fp-neutral-4Hover background
--fp-surface-active--fp-neutral-5Active/pressed background
--fp-surface-overlay--fp-neutral-1 light, --fp-neutral-3 darkMenus, popovers, dialogs
--fp-surface-inversethe other scheme’s pageTooltips, toasts
--fp-border-subtle-color--fp-neutral-6Subtle border
--fp-border-strong-color--fp-neutral-borderA control’s boundary (3:1)
--fp-text-subtle--fp-neutral-10Tertiary text
--fp-text-muted--fp-neutral-11Secondary text
--fp-text-quietbetween 11 and 12Lead-ins, descriptions
--fp-text-default--fp-neutral-12Default text
--fp-text-inversethe other scheme’s default textText on --fp-surface-inverse

Static colors

TokenDescription
--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):

TokenOpacityUse Case
--fp-{role}-a15%Ghost hover
--fp-{role}-a210%Subtle tint
--fp-{role}-a320%Active press
--fp-{role}-a430%Focus ring
--fp-{role}-a545%Badge / chip

Spacing Tokens

Three-layer architecture: Primitives -> DNA -> Semantics.

Primitives (--fp-dim-*)

Precomputed rem values (px / 16). Default scale (spacing.mode: "hybrid"):

TokenValuePixels (at 16px root)
--fp-dim-20.125rem2px (full stylesheet only)
--fp-dim-40.25rem4px
--fp-dim-60.375rem6px (full stylesheet only)
--fp-dim-80.5rem8px
--fp-dim-100.625rem10px (full stylesheet only)
--fp-dim-120.75rem12px
--fp-dim-161rem16px (full stylesheet only)
--fp-dim-201.25rem20px
--fp-dim-241.5rem24px
--fp-dim-322rem32px (full stylesheet only)
--fp-dim-402.5rem40px
--fp-dim-483rem48px (full stylesheet only)
--fp-dim-644rem64px (full stylesheet only)
--fp-dim-805rem80px
--fp-dim-966rem96px (full stylesheet only)
--fp-dim-1288rem128px

DNA (--fp-spacing-*)

TokenValueDescription
--fp-spacing-basevar(--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.

TokenMultiplierPixels (base=4)Description
--fp-s-10.5×2pxTightest (icon gaps)
--fp-s-21×4pxBase unit (inline padding)
--fp-s-31.5×6pxSmall gap
--fp-s-42×8pxStandard padding
--fp-s-53×12pxMedium gap
--fp-s-64×16pxSection padding
--fp-s-76×24pxLarge gap
--fp-s-88×32pxSection margin
--fp-s-912×48pxPage section
--fp-s-1016×64pxLarge section
--fp-s-1124×96pxHero section
--fp-s-1232×128pxMaximum 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-*)

TokenDefault ValueDescription
--fp-border-none0No border (full stylesheet only)
--fp-border-11px1px width (px, not rem — font-independent)
--fp-border-22px2px width
--fp-border-33px3px width (full stylesheet only)
--fp-border-44px4px width (full stylesheet only)
--fp-border-basevar(--fp-border-1)Configured base width
--fp-border-w-hairline1pxNamed width
--fp-border-w-thin1.5pxNamed width (full stylesheet only)
--fp-border-w-medium2pxNamed width
--fp-border-w-thick3pxNamed width
--fp-border-gradient-brandCSS gradientPrimary → secondary
--fp-border-gradient-subtleCSS gradientNeutral → primary → neutral
--fp-border-gradient-activeCSS gradientOnly when border.gradient.preset or .custom is set

Semantic (--fp-stroke-*) — use these

TokenValueDescription
--fp-stroke-hairlinevar(--fp-border-w-hairline)Thinnest borders
--fp-stroke-controlvar(--fp-border-base)Buttons, inputs, interactive controls
--fp-stroke-dividervar(--fp-border-w-hairline)Separators, table borders
--fp-stroke-strongvar(--fp-border-w-medium)Emphasized borders
--fp-stroke-accentvar(--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-*)

TokenDefault ValueDescription
--fp-radius-10.125remSmallest radius
--fp-radius-20.25remSmall radius
--fp-radius-30.375remMedium radius (full stylesheet only)
--fp-radius-40.5remLarge radius
--fp-radius-50.75remExtra large radius
--fp-radius-61remMaximum radius
--fp-radius-full9999pxFull circle
--fp-radius-basevar(--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

TokenValueDescription
--fp-corner-controlvar(--fp-radius-base)Buttons, inputs
--fp-corner-surfacevar(--fp-radius-4)Cards (8px)
--fp-corner-overlayvar(--fp-radius-5)Modals, overlays (12px)
--fp-corner-circlevar(--fp-radius-full)Avatars, full-circle elements
--fp-corner-shaperoundCorner 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

TokenDescription
--fp-shadow-tintShadow 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

TokenDescription
--fp-elevation-1Single drop shadow (subtle)
--fp-elevation-2Double drop shadow (raised)
--fp-elevation-3Double drop shadow (floating)
--fp-elevation-4Double 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

TokenDescription
--fp-surface-tint-1none (full stylesheet only)
--fp-surface-tint-23% neutral overlay (light) / 5% white (dark)
--fp-surface-tint-35% neutral overlay (light) / 8% white (dark)
--fp-surface-tint-47% 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

TokenSlot
--fp-font-family-displayHeadlines, hero copy, eyebrow
--fp-font-family-bodyParagraphs, UI text (default for most roles)
--fp-font-family-monoCode, 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

TokenPurpose
--fp-opacity-disabledGlobal opacity for disabled elements
--fp-transition-duration-xfastExtra-fast transition (default 75ms) (full stylesheet only)
--fp-transition-duration-fastFast transition (default 100ms)
--fp-transition-duration-normalNormal transition (default 150ms)
--fp-transition-duration-slowSlow transition (default 250ms)
--fp-transition-duration-xslowExtra-slow transition (default 400ms) (full stylesheet only)
--fp-transition-easing-ease-outDefault out easing curve
--fp-transition-easing-ease-in-outDefault in-out easing curve
--fp-transition-easing-linearLinear easing
--fp-focus-ring-widthStandard focus ring stroke width
--fp-focus-ring-offsetStandard focus ring offset distance
--fp-focus-ring-colorFocus ring colour (default var(--fp-primary-text))
--fp-scale-activeActive scale multiplier (e.g. 0.98)

Global scale tokens

TokenDefaultDescription
--fp-density1Spacing density multiplier; set it (or data-density) on <html>. Presets --fp-density-{compact,default,relaxed} = 0.75 / 1 / 1.25.
--fp-type-scale1Typographic scale multiplier; also drives the icon sizes below.
--fp-icon-size-smcalc(1rem * var(--fp-type-scale))16px icon at default scale
--fp-icon-size-mdcalc(1.25rem * var(--fp-type-scale))20px icon at default scale
--fp-icon-size-lgcalc(1.5rem * var(--fp-type-scale))24px icon at default scale
--fp-contrast-threshold0.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.