# Cortex > Cortex is a theme engine. From a `theme-config.json` with three brand colours (primary, secondary, neutral) it generates the design tokens a product needs: OKLCH colour ramps, text and border colours measured for contrast, type, spacing, shape, elevation and motion, as CSS custom properties with light and dark values. It runs at build time and works with any framework, or none. - Package: `@flexpixels/cortex` (Node, Bun, or the browser through `@flexpixels/cortex/browser`). MCP server for AI agents: `@flexpixels/cortex-mcp`. - `generateThemeCSS(config)` returns the lean stylesheet (599 tokens for this site's theme, the repository's `theme-config.json`); `generateFullThemeCSS(config)` returns every token the engine computes (1,034 for the same theme). - Every token name starts with `--fp-` (`settings.prefix` changes it). Light and dark values are `light-dark()` pairs; `data-theme="light"` or `"dark"` on `` pins one. ## Quick start - [Install Cortex](https://cortex.flexpixels.com/docs/quick-start/install/): Install @flexpixels/cortex, pick the right entry point, and see what the package gives you. - [Getting Started: Engine Only](https://cortex.flexpixels.com/docs/quick-start/engine-only/): Use FlexPixels tokens in your own components — React, Vue, Svelte, or vanilla CSS. - [Use Cortex in Angular](https://cortex.flexpixels.com/docs/quick-start/angular/): Generate the theme stylesheet before each Angular build, load it as a global style, use the tokens in components, and switch light and dark. - [Hello world](https://cortex.flexpixels.com/docs/quick-start/hello-world/): Generate your first cortex theme from a minimal config. - [theme-config.json reference](https://cortex.flexpixels.com/docs/quick-start/theme-config-reference/): Every field of theme-config.json, from seeds and settings to type, spacing, shape, elevation, vision palettes, layout and output. - [AI agents (MCP)](https://cortex.flexpixels.com/docs/quick-start/ai-agents/): Give an AI agent your tokens and theme with @flexpixels/cortex-mcp, the Cortex MCP server. ## Concepts - [OKLCH](https://cortex.flexpixels.com/docs/concepts/oklch/): Why cortex generates its palette in OKLCH instead of HSL or RGB, and how a hex seed becomes a 12-step ramp. - [Contrast](https://cortex.flexpixels.com/docs/concepts/contrast/): How cortex measures contrast with WCAG 2 and APCA, which tokens carry a contrast guarantee, and what the two contrast settings change. - [Perceptual color](https://cortex.flexpixels.com/docs/concepts/perceptual-color/): Why perceptual color spaces suit design systems better than sRGB, and the places in cortex that depend on it. ## Theme Engine - [Core Concepts](https://cortex.flexpixels.com/docs/theme/core-concepts/): The Cortex Theme Engine architecture — Three-Layer API, 12-step color scales, and the Dumb Serializer pattern. - [Color System](https://cortex.flexpixels.com/docs/theme/color-system/): OKLCH color scales, 12-step roles, contrast pairs, alpha stops, P3 wide-gamut, and dark mode — all from 3 hex seeds. - [Full palette](https://cortex.flexpixels.com/docs/theme/palette/): Every colour role's 12 steps and 5 alpha stops, painted from the theme this site runs on. - [Auto Contrast](https://cortex.flexpixels.com/docs/theme/auto-contrast/): A readable foreground derived in CSS for a colour nobody knew at build time — measured, with the accessibility floor proved over every sRGB colour. - [Vision Palettes](https://cortex.flexpixels.com/docs/theme/vision-variants/): Extra palettes for people who see colour differently (red–green, blue–yellow, monochrome, high contrast), generated, measured and picked by the visitor. - [Spacing System](https://cortex.flexpixels.com/docs/theme/spacing/): Three-Layer spacing — size primitives, DNA base, and semantic scale tokens (--fp-s-1 through --fp-s-12). - [Size & Density](https://cortex.flexpixels.com/docs/theme/sizing/): The size axis (sm / md / lg, --fp-size-*) and the density axis (--fp-density) — how big each thing is, and how tightly things are packed. - [Typography System](https://cortex.flexpixels.com/docs/theme/typography/): Font families, fluid sizes, type-style roles, leading trim, reading-comfort tokens, variable-font axes and scenario presets. - [Shape (Corners & Borders)](https://cortex.flexpixels.com/docs/theme/shape/): Radius, border width, semantic borders, gradient presets, and glow tokens — from two base values. - [Elevation System](https://cortex.flexpixels.com/docs/theme/elevation/): Shadow depths and surface tints, generated from a single chromatic shadow DNA. - [Interaction](https://cortex.flexpixels.com/docs/theme/interaction/): Transition durations, easing curves, focus ring tokens and opacity — for consistent interaction design. - [Motion](https://cortex.flexpixels.com/docs/theme/motion/): Two switches and a duration scale a page sets in CSS — transitions and animations, controlled separately, cheap by rule, and the same for every component. - [Layout System](https://cortex.flexpixels.com/docs/theme/layout/): Breakpoints, container max-widths, window size classes, grid tokens, density, touch targets, and responsive layout utilities. - [Custom Themes](https://cortex.flexpixels.com/docs/theme/custom-themes/): How to build your own design language with theme-config.json — the cortex engine turns one config file into a complete token system. - [Build & Import](https://cortex.flexpixels.com/docs/theme/build-and-import/): How to generate cortex theme CSS from your config and import it across Astro, Vite, Webpack, Next.js, Bun, and plain HTML. - [Token API Reference](https://cortex.flexpixels.com/docs/theme/token-api/): The families of CSS custom properties the Cortex engine generates, with their names and default values. - [Best Practices: Token Usage](https://cortex.flexpixels.com/docs/theme/best-practices-tokens/): How FlexPixels tokens actually work — the 12-step color scale, semantic layers, the two-tier hook pattern, and how to use them in your own CSS. ## Cortex API - [API overview](https://cortex.flexpixels.com/docs/api/overview/): The main public exports of @flexpixels/cortex, grouped by purpose, with the entry point for each. - [Runtime entry](https://cortex.flexpixels.com/docs/api/runtime/): @flexpixels/cortex/runtime: generate the theme CSS and check contrast in the browser, live, without zod. Its CSS is the full engine's, byte for byte. - [generateFullThemeCSS](https://cortex.flexpixels.com/docs/api/generate-full-theme-css/): The serializer that turns a theme config into a stylesheet of every token, and how it relates to generateThemeCSS, the lean default. - [ThemeEngine](https://cortex.flexpixels.com/docs/api/theme-engine/): A class that holds a validated theme config and its token tree: read computed tokens, check contrast at the theme’s level, or swap configs. - [Contrast helpers](https://cortex.flexpixels.com/docs/api/contrast/): The APCA and WCAG functions cortex uses to pick foreground colours, exported for build scripts, editor plugins and runtime checks. - [Validators & config merging](https://cortex.flexpixels.com/docs/api/validators/): The Zod schemas, what validation checks, and the difference between validateThemeConfig, mergeThemeConfig, mergeWithDefaults and deepMerge. - [DTCG export](https://cortex.flexpixels.com/docs/api/dtcg-export/): Export a cortex theme as W3C DTCG 2025.10 JSON for Figma Tokens, Style Dictionary and other token pipelines, and what Style Dictionary needs on top. - [DESIGN.md export](https://cortex.flexpixels.com/docs/api/design-md-export/): Generate a Markdown description of the resolved theme, for people and AI agents to read beside your code. - [Warnings](https://cortex.flexpixels.com/docs/api/warnings/): Non-blocking accessibility and readability checks on a theme config, returned as structured warnings (the MCP tools report the same ones). - [Config loader (Node)](https://cortex.flexpixels.com/docs/api/config-loader/): Node-only helpers for reading theme-config.json and producing a fully resolved ThemeConfig. - [Helpers, constants, metrics](https://cortex.flexpixels.com/docs/api/helpers-and-constants/): Token factories, DTCG type guards, schema constants, font metrics and typography metadata. - [A2UI bridge](https://cortex.flexpixels.com/docs/api/a2ui-bridge/): A stylesheet that maps the A2UI v0.9 basic-catalog CSS variables onto cortex tokens. ## Optional - [llms-full.txt](https://cortex.flexpixels.com/llms-full.txt): every page above as Markdown in one file, with the API list and the scale tables - [Configurator](https://cortex.flexpixels.com/configurator/): build a theme in the browser and download its CSS, config, DTCG tokens or DESIGN.md - [Markdown pages](https://cortex.flexpixels.com/docs/quick-start/install.md): each docs URL with .md in place of its final slash is the page as Markdown