Skip to content

Code draft v0.1.1

The syntax highlighting colors of code, one per category, and the states of marked lines, readable on every surface in every mode.

Code samples, token paths and snippets are set in the mono family (Typography foundation); this foundation colors them. Each syntax category (keyword, variable, function, class and type, string, number, comment) has a semantic color from the Figma library's code colors, global.text.code; the design system adds colors for diffs, invalid code and links, and backgrounds for marked lines, all picked from colors it already has. Everything else in code (plain identifiers, operators, punctuation) keeps the primary on-base text color. A highlighter maps the categories of its grammars to these colors: on the web, a Shiki theme generated from the tokens does it once for every mode, and a style sheet draws the marked lines.

Specification

From packages/components/specs/foundations/code.spec.json

Raw file packages/components/specs/foundations/code.spec.json
{
  "$schema": "../schema/foundation.schema.json",
  "id": "code",
  "name": "Code",
  "version": "0.1.1",
  "status": "draft",
  "summary": "The syntax highlighting colors of code, one per category, and the states of marked lines, readable on every surface in every mode.",
  "description": "Code samples, token paths and snippets are set in the mono family (Typography foundation); this foundation colors them. Each syntax category (keyword, variable, function, class and type, string, number, comment) has a semantic color from the Figma library's code colors, global.text.code; the design system adds colors for diffs, invalid code and links, and backgrounds for marked lines, all picked from colors it already has. Everything else in code (plain identifiers, operators, punctuation) keeps the primary on-base text color. A highlighter maps the categories of its grammars to these colors: on the web, a Shiki theme generated from the tokens does it once for every mode, and a style sheet draws the marked lines.",
  "tags": [
    "code",
    "color",
    "modes",
    "contrast"
  ],
  "tokens": [
    "global.text.code.*",
    "global.bg.code.*"
  ],
  "rules": [
    {
      "id": "categories",
      "name": "Categories",
      "text": "Seven categories are colored: keyword (language keywords and storage modifiers, markup tag names, CSS at-rules and pseudo-classes), variable (variables, parameters, properties and object keys, CSS properties and custom properties, markup attribute names, YAML keys), function (function and method names, CSS functions), class and type (class, type and built-in object names, CSS class and id selectors), string (strings, regular expressions, markup attribute values), number (numbers and language constants such as true, null, CSS units and keywords) and comment.",
      "tokens": [
        "global.text.code.keyword",
        "global.text.code.variable",
        "global.text.code.function",
        "global.text.code.class-and-type",
        "global.text.code.string",
        "global.text.code.number",
        "global.text.code.comment"
      ]
    },
    {
      "id": "more-categories",
      "name": "Diffs, invalid code and links",
      "text": "Five more text colors cover what is not syntax: inserted, deleted and changed for the lines of a diff (green, red and orange, the success, error and severe hues), invalid for code a grammar marks invalid or deprecated (the error hue), link for URLs and links (the brand hue). They are the design system's additions to the Figma library, picked from colors it already has: the steps of the matching text roles, moved to a passing step where a role fails on a surface.",
      "tokens": [
        "global.text.code.inserted",
        "global.text.code.deleted",
        "global.text.code.changed",
        "global.text.code.invalid",
        "global.text.code.link"
      ]
    },
    {
      "id": "plain",
      "name": "Plain code",
      "text": "What belongs to no category keeps the primary on-base text color (global.text.on-base.neutral.primary): plain identifiers a grammar does not classify, operators and punctuation. Highlighting only adds color to the structure; the code reads the same without it."
    },
    {
      "id": "markup",
      "name": "Markup",
      "text": "Markup languages reuse the categories: a heading or a list marker is a keyword, a quote a comment, inline code a string, a URL a link. Bold and italic keep the plain text color: their markers already show them."
    },
    {
      "id": "surface",
      "name": "Code surfaces",
      "text": "A block of code is a surface like any other: level 1 by default, raised on the page, or the level of the area it sits in. The colors are checked against every level and sunken, so a block can sit on any of them."
    },
    {
      "id": "line-states",
      "name": "Marked lines",
      "text": "An example can mark whole lines: highlighted (a line the author points out), inserted and deleted (lines an example adds or removes), error and warning. Each takes a background from the subtle fills (brand, success, error, warning) and a marker that does not rest on color: a bar for a highlighted line, + and - for inserted and deleted lines, x and ! for errors and warnings. Every code color stays readable on every line background.",
      "tokens": [
        "global.bg.code.*"
      ]
    },
    {
      "id": "line-meaning",
      "name": "Say why a line is marked",
      "text": "A marker shows that a line is marked; the text around the example says why (what changed, what the error is). Markers are a visual aid, not the only place the information lives."
    },
    {
      "id": "inline-and-numbers",
      "name": "Inline code and line numbers",
      "text": "Code inside running text sits on the neutral subtle fill (global.bg.subtle.neutral.default) and keeps the syntax colors' contrast rules. Line numbers, when a block shows them, use the tertiary on-base text color (global.text.on-base.neutral.tertiary). Neither needs a code token."
    },
    {
      "id": "typography",
      "name": "Typography",
      "text": "Code is set in the mono family (Typography foundation). Highlighting changes the color only: the text style stays the same for every category."
    },
    {
      "id": "modes",
      "name": "Modes",
      "text": "Every color has a value in every mode: the syntax categories take step 700 of each hue in light mode and the light steps (200 to 400) in dark mode; the line backgrounds follow the subtle fills. One highlighting definition serves every mode: it names the categories, the mode picks the values.",
      "tokens": [
        "global.text.code.*",
        "global.bg.code.*"
      ]
    },
    {
      "id": "languages",
      "name": "Languages",
      "text": "The categories hold for any language. The mapping is written and checked for CSS, HTML, JavaScript, JSON, shell, YAML, diff and Markdown, the languages the documentation shows; a new language may need new scopes in the mapping, never a new color."
    },
    {
      "id": "web-theme",
      "name": "Shiki theme",
      "text": "pnpm tokens:build writes packages/tokens/dist/shiki-theme.json (@quantum-ds/tokens/shiki-theme.json) from the code tokens and the scope mapping in tokens.config.json (syntax): one theme in the TextMate format Shiki reads, whose colors are the CSS variables of the tokens. It follows the mode of every data-theme context without a light and dark pair, and needs the design system's token CSS on the page. Marked lines come from Shiki's notation transformers ([!code highlight], [!code ++], [!code --], [!code error], [!code warning]); web/foundations/code.css, imported by web/index.css, draws them from the global.bg.code.* tokens with their default class names.",
      "platforms": [
        "web"
      ]
    },
    {
      "id": "platform-trees",
      "name": "Other platforms",
      "text": "The code colors are semantic tokens: iOS and Android get them in their resolved trees for every mode, for a highlighter of their own to map its categories to.",
      "platforms": [
        "ios",
        "android"
      ]
    }
  ],
  "specimens": [
    {
      "id": "code-roles",
      "name": "Syntax colors",
      "display": "color",
      "tokens": [
        "global.text.code.*"
      ],
      "description": "One color per syntax category, and the additions for diffs, invalid code and links, with the palette step each aliases in every mode."
    },
    {
      "id": "line-backgrounds",
      "name": "Line backgrounds",
      "display": "color",
      "tokens": [
        "global.bg.code.*"
      ],
      "description": "Backgrounds of marked lines, aliasing the subtle fills."
    }
  ],
  "contrast": [
    {
      "id": "keyword",
      "description": "Keywords are text: on every surface level and sunken, and on every line background.",
      "foreground": "global.text.code.keyword",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "variable",
      "description": "Variables and properties, on every surface and every line background.",
      "foreground": "global.text.code.variable",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "function",
      "description": "Function names, on every surface and every line background.",
      "foreground": "global.text.code.function",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "class-and-type",
      "description": "Class and type names, on every surface and every line background.",
      "foreground": "global.text.code.class-and-type",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "string",
      "description": "Strings, on every surface and every line background.",
      "foreground": "global.text.code.string",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "number",
      "description": "Numbers and constants, on every surface and every line background.",
      "foreground": "global.text.code.number",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "comment",
      "description": "Comments are text people read, not decoration: same minimum as the rest of the code.",
      "foreground": "global.text.code.comment",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "inserted",
      "description": "Lines a diff adds. Text: on every surface and every line background.",
      "foreground": "global.text.code.inserted",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "deleted",
      "description": "Lines a diff removes. Text: on every surface and every line background.",
      "foreground": "global.text.code.deleted",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "changed",
      "description": "Lines a context diff changes. Text: on every surface and every line background.",
      "foreground": "global.text.code.changed",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "invalid",
      "description": "Invalid or deprecated code. Text: on every surface and every line background.",
      "foreground": "global.text.code.invalid",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "link",
      "description": "URLs and links in code and markup. Text: on every surface and every line background.",
      "foreground": "global.text.code.link",
      "backgrounds": [
        "global.bg.level.0.default",
        "global.bg.level.1.default",
        "global.bg.level.2.default",
        "global.bg.level.3.default",
        "global.bg.level.sunken.default",
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "plain-on-lines",
      "description": "Plain code (identifiers, operators, punctuation) and the markers on every line background.",
      "foreground": "global.text.on-base.neutral.primary",
      "backgrounds": [
        "global.bg.code.*"
      ],
      "minimum": 4.5,
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "line-highlighted-tint",
      "description": "The highlighted line background against the default code block (level 1). Measured only: the marker, not the tint, shows the state.",
      "foreground": "global.bg.code.highlighted",
      "backgrounds": [
        "global.bg.level.1.default"
      ],
      "refs": [
        "wcag:1.4.1",
        "wcag:1.4.11"
      ]
    },
    {
      "id": "line-inserted-tint",
      "description": "The inserted line background against the default code block (level 1). Measured only: the marker, not the tint, shows the state.",
      "foreground": "global.bg.code.inserted",
      "backgrounds": [
        "global.bg.level.1.default"
      ],
      "refs": [
        "wcag:1.4.1",
        "wcag:1.4.11"
      ]
    },
    {
      "id": "line-deleted-tint",
      "description": "The deleted line background against the default code block (level 1). Measured only: the marker, not the tint, shows the state.",
      "foreground": "global.bg.code.deleted",
      "backgrounds": [
        "global.bg.level.1.default"
      ],
      "refs": [
        "wcag:1.4.1",
        "wcag:1.4.11"
      ]
    },
    {
      "id": "line-error-tint",
      "description": "The error line background against the default code block (level 1). Measured only: the marker, not the tint, shows the state.",
      "foreground": "global.bg.code.error",
      "backgrounds": [
        "global.bg.level.1.default"
      ],
      "refs": [
        "wcag:1.4.1",
        "wcag:1.4.11"
      ]
    },
    {
      "id": "line-warning-tint",
      "description": "The warning line background against the default code block (level 1). Measured only: the marker, not the tint, shows the state.",
      "foreground": "global.bg.code.warning",
      "backgrounds": [
        "global.bg.level.1.default"
      ],
      "refs": [
        "wcag:1.4.1",
        "wcag:1.4.11"
      ]
    }
  ],
  "accessibility": {
    "guidelines": [
      {
        "text": "Every code color, comments, diff and link colors included, contrasts at least 4.5:1 with every surface level and sunken and with every line background, in every mode: code is text, whatever its category.",
        "refs": [
          "wcag:1.4.3"
        ]
      },
      {
        "text": "Color is not the only way to tell the categories apart: highlighting adds no information that the code text does not already carry, so a reader who cannot see the colors misses nothing.",
        "refs": [
          "wcag:1.4.1"
        ]
      },
      {
        "text": "A marked line never shows its state by color alone: a bar, + and -, x and ! mark it, and they survive forced colors mode, where the line backgrounds disappear.",
        "refs": [
          "wcag:1.4.1"
        ]
      },
      {
        "text": "Markers are generated content, which some assistive technologies do not announce. They carry alternative text (Added, Removed, Error, Warning) for those that do, and the text around an example says what its marked lines mean, so the information does not depend on the presentation.",
        "refs": [
          "wcag:1.3.1",
          "mdn-content-alt",
          "mdn-content-a11y"
        ],
        "platforms": [
          "web"
        ]
      },
      {
        "text": "In forced colors mode the browser replaces the color of every syntax category, and the background of the block, with system colors: the code stays readable, without highlighting. Nothing may depend on a syntax color surviving there.",
        "refs": [
          "mdn-forced-colors"
        ],
        "platforms": [
          "web"
        ]
      }
    ],
    "references": [
      {
        "id": "mdn-forced-colors",
        "title": "MDN: forced-colors, properties affected by forced colors mode",
        "url": "https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/forced-colors#properties_affected_by_forced-color_mode"
      },
      {
        "id": "mdn-content-alt",
        "title": "MDN: content, alternative text",
        "url": "https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content#alternative_text_string_counter_attr"
      },
      {
        "id": "mdn-content-a11y",
        "title": "MDN: content, accessibility",
        "url": "https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content#accessibility"
      }
    ]
  },
  "examples": [
    {
      "id": "javascript",
      "name": "JavaScript",
      "description": "A module with a class, private fields, a getter, regular expressions, template literals and async functions.",
      "source": "packages/components/specs/foundations/code/contrast.js"
    },
    {
      "id": "css",
      "name": "CSS",
      "description": "A product stylesheet: cascade layers, custom properties, functions, selectors, units and a media query.",
      "source": "packages/components/specs/foundations/code/cards.css"
    },
    {
      "id": "html",
      "name": "HTML",
      "description": "A page using the Dropdown markup, with an embedded style sheet, a comment, an entity and a module script.",
      "source": "packages/components/specs/foundations/code/dropdown.html"
    },
    {
      "id": "json",
      "name": "JSON",
      "description": "A DTCG token file: keys, strings, numbers, booleans and null.",
      "source": "packages/components/specs/foundations/code/tokens.json"
    },
    {
      "id": "shell",
      "name": "Shell",
      "description": "A release script: variables, expansions, functions, conditions and loops.",
      "source": "packages/components/specs/foundations/code/release.sh"
    },
    {
      "id": "yaml",
      "name": "YAML",
      "description": "A CI configuration: anchors, aliases, flow collections and multi-line lists.",
      "source": "packages/components/specs/foundations/code/ci.yml"
    },
    {
      "id": "notation",
      "name": "Marked lines",
      "description": "A JavaScript module whose lines are marked: the old themes option is removed and replaced (- and +), the render call is highlighted, a call with an unknown language is an error, a call without a language a warning.",
      "source": "packages/components/specs/foundations/code/notation.js"
    },
    {
      "id": "diff",
      "name": "Diff",
      "description": "A context diff of the code colors: changed lines (!), an added line (+), a removed line (-), headers and ranges.",
      "source": "packages/components/specs/foundations/code/tokens.diff"
    },
    {
      "id": "markdown",
      "name": "Markdown",
      "description": "A README: heading, quote, bold and italic, list, inline code, a link and a fenced JavaScript block.",
      "source": "packages/components/specs/foundations/code/readme.md"
    },
    {
      "id": "invalid",
      "name": "Invalid JSON",
      "description": "A token file with two errors: a missing comma after keyword and an unquoted comment key, both marked invalid.",
      "source": "packages/components/specs/foundations/code/broken.json"
    }
  ],
  "decisions": [
    {
      "id": "code-additions",
      "date": "2026-10-02",
      "version": "0.1.0",
      "area": "color",
      "status": "active",
      "text": "The design system adds, from colors it already has: text colors global.text.code.inserted (light success 700, dark success 300), deleted and invalid (light error 600, dark error 200), changed (light severe 700, dark severe 300) and link (light brand 600, dark brand dark 200), mapped to diffs, invalid code and URLs; line backgrounds global.bg.code.highlighted, inserted, deleted, error and warning, aliasing the subtle brand, success, error, error and warning fills. Markup reuses the syntax categories. Marked lines also carry a marker (bar, +, -, x, !).",
      "tokens": [
        "global.text.code.inserted",
        "global.text.code.deleted",
        "global.text.code.changed",
        "global.text.code.invalid",
        "global.text.code.link",
        "global.bg.code.*"
      ]
    },
    {
      "id": "shiki-theme",
      "date": "2026-10-02",
      "version": "0.1.0",
      "area": "platform",
      "status": "active",
      "text": "On the web, code is highlighted with Shiki, through one theme generated from the tokens (web/shiki-theme.json) whose colors are the CSS variables of the code tokens (var(--global-text-code-keyword)…). The same theme serves every mode; the documentation site uses it for every code block.",
      "tokens": [
        "global.text.code.*"
      ],
      "platforms": [
        "web"
      ]
    },
    {
      "id": "code-colors-contrast",
      "date": "2026-10-02",
      "version": "0.1.0",
      "area": "accessibility",
      "status": "active",
      "text": "Every syntax color reaches 4.5:1 on every surface level and sunken, in every mode. Where the Figma library's step does not, the color takes the nearest step of the same hue that does: light class and type amber 700 (the Figma library 500), string forest 700 (600), number coral 700 (500); dark string forest 400 (500), comment dark-switch base 300 (400). Light mode is then step 700 of every hue and light-switch base 700 for comments; dark mode step 400 and dark-switch base 300.",
      "tokens": [
        "global.text.code.class-and-type",
        "global.text.code.string",
        "global.text.code.number",
        "global.text.code.comment"
      ],
      "refs": [
        "wcag:1.4.3"
      ]
    },
    {
      "id": "code-colors",
      "date": "2026-10-02",
      "version": "0.1.0",
      "area": "color",
      "status": "active",
      "text": "Code syntax highlighting has seven semantic colors, the Figma library's code colors global.text.code: keyword (lavender), variable (orchid), function (azure), class and type (amber), string (forest), number (coral) and comment (neutral). Anything else in code keeps the primary on-base text color, global.text.on-base.neutral.primary.",
      "tokens": [
        "global.text.code.*"
      ]
    }
  ],
  "changelog": [
    {
      "version": "0.1.1",
      "date": "2026-10-22",
      "note": "Fix, no decision changed: the CSS and HTML samples (cards.css, dropdown.html) no longer load the component styles from @quantum-ds/components, which publishes the specs only; they load the component styles the product implemented from the specs."
    },
    {
      "version": "0.1.0",
      "date": "2026-10-02",
      "note": "Initial draft, decisions code-colors, code-colors-contrast, code-additions and shiki-theme. Owns the Figma library's global.text.code.* (keyword, variable, function, class-and-type, string, number, comment); five of them move to a passing step (light class-and-type, string, number; dark string, comment), the only divergences from the Figma library (pnpm tokens:figma-library). Adds, in tokens/additions/: global.text.code.inserted, deleted, changed, invalid, link, and the line backgrounds global.bg.code.highlighted, inserted, deleted, error, warning. New outputs web/shiki-theme.json (generated) and web/foundations/code.css (marked lines). Contrast, lowest over every surface level, sunken and line background, every platform (4.5:1 required, WCAG 1.4.3): light keyword 6.51:1, variable 5.82:1, function 5.85:1, class and type 4.90:1, string 6.43:1, number 5.67:1, comment 7.71:1, inserted 7.01:1, deleted and invalid 5.45:1, changed 7.31:1, link 5.16:1, plain code 17.00:1 (all lowest on the error line background); dark keyword 4.51:1, variable 5.59:1, function 5.94:1, class and type 7.25:1, string 5.78:1, number 5.73:1, comment 4.77:1, inserted 5.92:1, deleted and invalid 6.96:1, changed 5.35:1, link 9.61:1 (level 3), plain code 11.42:1. Measured only: line backgrounds against the level 1 block, light 1.03 to 1.05:1, dark 1.10 to 1.12:1 (the markers carry the state, WCAG 1.4.1)."
    }
  ]
}

Rules

What the foundation is, one aspect per rule. The values come from the tokens, shown in every mode where they differ.

AspectRuleTokens
Categories Seven categories are colored: keyword (language keywords and storage modifiers, markup tag names, CSS at-rules and pseudo-classes), variable (variables, parameters, properties and object keys, CSS properties and custom properties, markup attribute names, YAML keys), function (function and method names, CSS functions), class and type (class, type and built-in object names, CSS class and id selectors), string (strings, regular expressions, markup attribute values), number (numbers and language constants such as true, null, CSS units and keywords) and comment.
global.text.code.keyword
light #7534A9
dark #B87BF5
global.text.code.variable
light #923D78
dark #F283CD
global.text.code.function
light #266280
dark #5BB8E7
global.text.code.class-and-type
light #7F6426
dark #EEB836
global.text.code.string
light #18614E
dark #68BBA1
global.text.code.number
light #9C4324
dark #FD8C67
global.text.code.comment
light #4C4A4A
dark #9D9B9C
Diffs, invalid code and links Five more text colors cover what is not syntax: inserted, deleted and changed for the lines of a diff (green, red and orange, the success, error and severe hues), invalid for code a grammar marks invalid or deprecated (the error hue), link for URLs and links (the brand hue). They are the design system's additions to the Figma library, picked from colors it already has: the steps of the matching text roles, moved to a passing step where a role fails on a surface.
global.text.code.inserted
light #075D33
dark #11C772
global.text.code.deleted
light #C01619
dark #FAA79D
global.text.code.changed
light #764016
dark #FE8400
global.text.code.invalid
light #C01619
dark #FAA79D
global.text.code.link
light #175DD6
dark #9EE7FA
Plain code What belongs to no category keeps the primary on-base text color (global.text.on-base.neutral.primary): plain identifiers a grammar does not classify, operators and punctuation. Highlighting only adds color to the structure; the code reads the same without it. —
Markup Markup languages reuse the categories: a heading or a list marker is a keyword, a quote a comment, inline code a string, a URL a link. Bold and italic keep the plain text color: their markers already show them. —
Code surfaces A block of code is a surface like any other: level 1 by default, raised on the page, or the level of the area it sits in. The colors are checked against every level and sunken, so a block can sit on any of them. —
Marked lines An example can mark whole lines: highlighted (a line the author points out), inserted and deleted (lines an example adds or removes), error and warning. Each takes a background from the subtle fills (brand, success, error, warning) and a marker that does not rest on color: a bar for a highlighted line, + and - for inserted and deleted lines, x and ! for errors and warnings. Every code color stays readable on every line background.
global.bg.code.highlighted
light #EEF1F7
dark #09191D
global.bg.code.inserted
light #DBFAE6
dark #011C16
global.bg.code.deleted
light #FEECEA
dark #2B0B08
global.bg.code.error
light #FEECEA
dark #2B0B08
global.bg.code.warning
light #FFF1C7
dark #1F1504
Say why a line is marked A marker shows that a line is marked; the text around the example says why (what changed, what the error is). Markers are a visual aid, not the only place the information lives. —
Inline code and line numbers Code inside running text sits on the neutral subtle fill (global.bg.subtle.neutral.default) and keeps the syntax colors' contrast rules. Line numbers, when a block shows them, use the tertiary on-base text color (global.text.on-base.neutral.tertiary). Neither needs a code token. —
Typography Code is set in the mono family (Typography foundation). Highlighting changes the color only: the text style stays the same for every category. —
Modes Every color has a value in every mode: the syntax categories take step 700 of each hue in light mode and the light steps (200 to 400) in dark mode; the line backgrounds follow the subtle fills. One highlighting definition serves every mode: it names the categories, the mode picks the values.
global.bg.code.highlighted
light #EEF1F7
dark #09191D
global.bg.code.inserted
light #DBFAE6
dark #011C16
global.bg.code.deleted
light #FEECEA
dark #2B0B08
global.bg.code.error
light #FEECEA
dark #2B0B08
global.bg.code.warning
light #FFF1C7
dark #1F1504
global.text.code.keyword
light #7534A9
dark #B87BF5
global.text.code.variable
light #923D78
dark #F283CD
global.text.code.function
light #266280
dark #5BB8E7
global.text.code.class-and-type
light #7F6426
dark #EEB836
global.text.code.string
light #18614E
dark #68BBA1
global.text.code.number
light #9C4324
dark #FD8C67
global.text.code.comment
light #4C4A4A
dark #9D9B9C
global.text.code.inserted
light #075D33
dark #11C772
global.text.code.deleted
light #C01619
dark #FAA79D
global.text.code.changed
light #764016
dark #FE8400
global.text.code.invalid
light #C01619
dark #FAA79D
global.text.code.link
light #175DD6
dark #9EE7FA
Languages The categories hold for any language. The mapping is written and checked for CSS, HTML, JavaScript, JSON, shell, YAML, diff and Markdown, the languages the documentation shows; a new language may need new scopes in the mapping, never a new color. —
Shiki theme
Web
pnpm tokens:build writes packages/tokens/dist/shiki-theme.json (@quantum-ds/tokens/shiki-theme.json) from the code tokens and the scope mapping in tokens.config.json (syntax): one theme in the TextMate format Shiki reads, whose colors are the CSS variables of the tokens. It follows the mode of every data-theme context without a light and dark pair, and needs the design system's token CSS on the page. Marked lines come from Shiki's notation transformers ([!code highlight], [!code ++], [!code --], [!code error], [!code warning]); web/foundations/code.css, imported by web/index.css, draws them from the global.bg.code.* tokens with their default class names. —
Other platforms
iOS, Android
The code colors are semantic tokens: iOS and Android get them in their resolved trees for every mode, for a highlighter of their own to map its categories to. —

Contrast

Computed from the resolved tokens in every platform and mode, as pnpm validate does; a pair under its minimum fails the check, a pair without minimum is measured only. Translucent colors are composited first: a translucent background over each surface it sits on.

global.text.code.keyword on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Keywords are text: on every surface level and sunken, and on every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #7534a9 on #fdfdfd 7.31:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #7534a9 on #f7f6f6 6.89:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #7534a9 on #fdfdfd 7.31:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #7534a9 on #f7f6f6 6.89:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #7534a9 on #f7f6f6 6.89:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #7534a9 on #eef1f7 6.58:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #7534a9 on #dbfae6 6.66:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #7534a9 on #feecea 6.51:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #7534a9 on #feecea 6.51:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #7534a9 on #fff1c7 6.60:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #b87bf5 on #191919 6.01:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #b87bf5 on #212121 5.51:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #b87bf5 on #282828 5.04:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #b87bf5 on #303030 4.51:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #b87bf5 on #141414 6.30:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #b87bf5 on #09191d 6.13:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #b87bf5 on #011c16 6.09:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #b87bf5 on #2b0b08 6.22:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #b87bf5 on #2b0b08 6.22:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #b87bf5 on #1f1504 6.15:1 passes Web, Desktop · iOS · Android

global.text.code.variable on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Variables and properties, on every surface and every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #923d78 on #fdfdfd 6.53:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #923d78 on #f7f6f6 6.15:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #923d78 on #fdfdfd 6.53:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #923d78 on #f7f6f6 6.15:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #923d78 on #f7f6f6 6.15:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #923d78 on #eef1f7 5.88:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #923d78 on #dbfae6 5.95:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #923d78 on #feecea 5.82:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #923d78 on #feecea 5.82:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #923d78 on #fff1c7 5.90:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #f283cd on #191919 7.45:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #f283cd on #212121 6.82:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #f283cd on #282828 6.25:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #f283cd on #303030 5.59:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #f283cd on #141414 7.81:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #f283cd on #09191d 7.59:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #f283cd on #011c16 7.55:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #f283cd on #2b0b08 7.71:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #f283cd on #2b0b08 7.71:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #f283cd on #1f1504 7.62:1 passes Web, Desktop · iOS · Android

global.text.code.function on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Function names, on every surface and every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #266280 on #fdfdfd 6.56:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #266280 on #f7f6f6 6.19:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #266280 on #fdfdfd 6.56:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #266280 on #f7f6f6 6.19:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #266280 on #f7f6f6 6.19:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #266280 on #eef1f7 5.91:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #266280 on #dbfae6 5.99:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #266280 on #feecea 5.85:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #266280 on #feecea 5.85:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #266280 on #fff1c7 5.93:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #5bb8e7 on #191919 7.91:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #5bb8e7 on #212121 7.24:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #5bb8e7 on #282828 6.63:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #5bb8e7 on #303030 5.94:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #5bb8e7 on #141414 8.29:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #5bb8e7 on #09191d 8.06:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #5bb8e7 on #011c16 8.01:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #5bb8e7 on #2b0b08 8.19:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #5bb8e7 on #2b0b08 8.19:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #5bb8e7 on #1f1504 8.09:1 passes Web, Desktop · iOS · Android

global.text.code.class-and-type on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Class and type names, on every surface and every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #7f6426 on #fdfdfd 5.49:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #7f6426 on #f7f6f6 5.18:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #7f6426 on #fdfdfd 5.49:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #7f6426 on #f7f6f6 5.18:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #7f6426 on #f7f6f6 5.18:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #7f6426 on #eef1f7 4.95:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #7f6426 on #dbfae6 5.01:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #7f6426 on #feecea 4.90:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #7f6426 on #feecea 4.90:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #7f6426 on #fff1c7 4.97:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #eeb836 on #191919 9.66:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #eeb836 on #212121 8.85:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #eeb836 on #282828 8.10:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #eeb836 on #303030 7.25:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #eeb836 on #141414 10.12:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #eeb836 on #09191d 9.84:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #eeb836 on #011c16 9.79:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #eeb836 on #2b0b08 10.00:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #eeb836 on #2b0b08 10.00:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #eeb836 on #1f1504 9.89:1 passes Web, Desktop · iOS · Android

global.text.code.string on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Strings, on every surface and every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #18614e on #fdfdfd 7.22:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #18614e on #f7f6f6 6.80:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #18614e on #fdfdfd 7.22:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #18614e on #f7f6f6 6.80:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #18614e on #f7f6f6 6.80:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #18614e on #eef1f7 6.50:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #18614e on #dbfae6 6.58:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #18614e on #feecea 6.43:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #18614e on #feecea 6.43:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #18614e on #fff1c7 6.52:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #68bba1 on #191919 7.71:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #68bba1 on #212121 7.06:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #68bba1 on #282828 6.46:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #68bba1 on #303030 5.78:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #68bba1 on #141414 8.08:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #68bba1 on #09191d 7.85:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #68bba1 on #011c16 7.81:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #68bba1 on #2b0b08 7.98:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #68bba1 on #2b0b08 7.98:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #68bba1 on #1f1504 7.89:1 passes Web, Desktop · iOS · Android

global.text.code.number on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Numbers and constants, on every surface and every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #9c4324 on #fdfdfd 6.36:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #9c4324 on #f7f6f6 6.00:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #9c4324 on #fdfdfd 6.36:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #9c4324 on #f7f6f6 6.00:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #9c4324 on #f7f6f6 6.00:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #9c4324 on #eef1f7 5.73:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #9c4324 on #dbfae6 5.80:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #9c4324 on #feecea 5.67:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #9c4324 on #feecea 5.67:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #9c4324 on #fff1c7 5.75:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #fd8c67 on #191919 7.63:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #fd8c67 on #212121 6.99:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #fd8c67 on #282828 6.40:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #fd8c67 on #303030 5.73:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #fd8c67 on #141414 8.00:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #fd8c67 on #09191d 7.78:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #fd8c67 on #011c16 7.73:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #fd8c67 on #2b0b08 7.90:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #fd8c67 on #2b0b08 7.90:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #fd8c67 on #1f1504 7.81:1 passes Web, Desktop · iOS · Android

global.text.code.comment on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Comments are text people read, not decoration: same minimum as the rest of the code. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #4c4a4a on #fdfdfd 8.65:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #4c4a4a on #f7f6f6 8.16:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #4c4a4a on #fdfdfd 8.65:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #4c4a4a on #f7f6f6 8.16:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #4c4a4a on #f7f6f6 8.16:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #4c4a4a on #eef1f7 7.79:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #4c4a4a on #dbfae6 7.89:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #4c4a4a on #feecea 7.71:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #4c4a4a on #feecea 7.71:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #4c4a4a on #fff1c7 7.82:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #9d9b9c on #191919 6.36:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #9d9b9c on #212121 5.83:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #9d9b9c on #282828 5.33:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #9d9b9c on #303030 4.77:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #9d9b9c on #141414 6.67:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #9d9b9c on #09191d 6.48:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #9d9b9c on #011c16 6.44:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #9d9b9c on #2b0b08 6.58:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #9d9b9c on #2b0b08 6.58:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #9d9b9c on #1f1504 6.51:1 passes Web, Desktop · iOS · Android

global.text.code.inserted on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Lines a diff adds. Text: on every surface and every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #075d33 on #fdfdfd 7.87:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #075d33 on #f7f6f6 7.42:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #075d33 on #fdfdfd 7.87:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #075d33 on #f7f6f6 7.42:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #075d33 on #f7f6f6 7.42:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #075d33 on #eef1f7 7.08:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #075d33 on #dbfae6 7.18:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #075d33 on #feecea 7.01:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #075d33 on #feecea 7.01:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #075d33 on #fff1c7 7.11:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #11c772 on #191919 7.89:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #11c772 on #212121 7.23:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #11c772 on #282828 6.62:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #11c772 on #303030 5.92:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #11c772 on #141414 8.27:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #11c772 on #09191d 8.04:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #11c772 on #011c16 8.00:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #11c772 on #2b0b08 8.17:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #11c772 on #2b0b08 8.17:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #11c772 on #1f1504 8.08:1 passes Web, Desktop · iOS · Android

global.text.code.deleted on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Lines a diff removes. Text: on every surface and every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #c01619 on #fdfdfd 6.12:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #c01619 on #f7f6f6 5.77:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #c01619 on #fdfdfd 6.12:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #c01619 on #f7f6f6 5.77:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #c01619 on #f7f6f6 5.77:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #c01619 on #eef1f7 5.51:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #c01619 on #dbfae6 5.58:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #c01619 on #feecea 5.45:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #c01619 on #feecea 5.45:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #c01619 on #fff1c7 5.53:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #faa79d on #191919 9.27:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #faa79d on #212121 8.49:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #faa79d on #282828 7.77:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #faa79d on #303030 6.96:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #faa79d on #141414 9.72:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #faa79d on #09191d 9.44:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #faa79d on #011c16 9.39:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #faa79d on #2b0b08 9.60:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #faa79d on #2b0b08 9.60:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #faa79d on #1f1504 9.49:1 passes Web, Desktop · iOS · Android

global.text.code.changed on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Lines a context diff changes. Text: on every surface and every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #764016 on #fdfdfd 8.20:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #764016 on #f7f6f6 7.73:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #764016 on #fdfdfd 8.20:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #764016 on #f7f6f6 7.73:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #764016 on #f7f6f6 7.73:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #764016 on #eef1f7 7.38:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #764016 on #dbfae6 7.48:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #764016 on #feecea 7.31:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #764016 on #feecea 7.31:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #764016 on #fff1c7 7.41:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #fe8400 on #191919 7.12:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #fe8400 on #212121 6.52:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #fe8400 on #282828 5.97:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #fe8400 on #303030 5.35:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #fe8400 on #141414 7.46:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #fe8400 on #09191d 7.26:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #fe8400 on #011c16 7.22:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #fe8400 on #2b0b08 7.37:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #fe8400 on #2b0b08 7.37:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #fe8400 on #1f1504 7.29:1 passes Web, Desktop · iOS · Android

global.text.code.invalid on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

Invalid or deprecated code. Text: on every surface and every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #c01619 on #fdfdfd 6.12:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #c01619 on #f7f6f6 5.77:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #c01619 on #fdfdfd 6.12:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #c01619 on #f7f6f6 5.77:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #c01619 on #f7f6f6 5.77:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #c01619 on #eef1f7 5.51:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #c01619 on #dbfae6 5.58:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #c01619 on #feecea 5.45:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #c01619 on #feecea 5.45:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #c01619 on #fff1c7 5.53:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #faa79d on #191919 9.27:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #faa79d on #212121 8.49:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #faa79d on #282828 7.77:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #faa79d on #303030 6.96:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #faa79d on #141414 9.72:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #faa79d on #09191d 9.44:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #faa79d on #011c16 9.39:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #faa79d on #2b0b08 9.60:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #faa79d on #2b0b08 9.60:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #faa79d on #1f1504 9.49:1 passes Web, Desktop · iOS · Android

global.text.code.link on global.bg.level.0.default, global.bg.level.1.default, global.bg.level.2.default, global.bg.level.3.default, global.bg.level.sunken.default, global.bg.code.*

URLs and links in code and markup. Text: on every surface and every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.0.default #175dd6 on #fdfdfd 5.79:1 passes Web, Desktop · iOS · Android
light global.bg.level.1.default #175dd6 on #f7f6f6 5.46:1 passes Web, Desktop · iOS · Android
light global.bg.level.2.default #175dd6 on #fdfdfd 5.79:1 passes Web, Desktop · iOS · Android
light global.bg.level.3.default #175dd6 on #f7f6f6 5.46:1 passes Web, Desktop · iOS · Android
light global.bg.level.sunken.default #175dd6 on #f7f6f6 5.46:1 passes Web, Desktop · iOS · Android
light global.bg.code.highlighted #175dd6 on #eef1f7 5.22:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #175dd6 on #dbfae6 5.28:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #175dd6 on #feecea 5.16:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #175dd6 on #feecea 5.16:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #175dd6 on #fff1c7 5.24:1 passes Web, Desktop · iOS · Android
dark global.bg.level.0.default #9ee7fa on #191919 12.80:1 passes Web, Desktop · iOS · Android
dark global.bg.level.1.default #9ee7fa on #212121 11.72:1 passes Web, Desktop · iOS · Android
dark global.bg.level.2.default #9ee7fa on #282828 10.73:1 passes Web, Desktop · iOS · Android
dark global.bg.level.3.default #9ee7fa on #303030 9.61:1 passes Web, Desktop · iOS · Android
dark global.bg.level.sunken.default #9ee7fa on #141414 13.41:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #9ee7fa on #09191d 13.04:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #9ee7fa on #011c16 12.97:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #9ee7fa on #2b0b08 13.25:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #9ee7fa on #2b0b08 13.25:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #9ee7fa on #1f1504 13.10:1 passes Web, Desktop · iOS · Android

global.text.on-base.neutral.primary on global.bg.code.*

Plain code (identifiers, operators, punctuation) and the markers on every line background. Minimum 4.5:1. WCAG 1.4.3 Contrast (Minimum) (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.code.highlighted #0e0d0d on #eef1f7 17.17:1 passes Web, Desktop · iOS · Android
light global.bg.code.inserted #0e0d0d on #dbfae6 17.40:1 passes Web, Desktop · iOS · Android
light global.bg.code.deleted #0e0d0d on #feecea 17.00:1 passes Web, Desktop · iOS · Android
light global.bg.code.error #0e0d0d on #feecea 17.00:1 passes Web, Desktop · iOS · Android
light global.bg.code.warning #0e0d0d on #fff1c7 17.24:1 passes Web, Desktop · iOS · Android
dark global.bg.code.highlighted #d2cecf on #09191d 11.48:1 passes Web, Desktop · iOS · Android
dark global.bg.code.inserted #d2cecf on #011c16 11.42:1 passes Web, Desktop · iOS · Android
dark global.bg.code.deleted #d2cecf on #2b0b08 11.67:1 passes Web, Desktop · iOS · Android
dark global.bg.code.error #d2cecf on #2b0b08 11.67:1 passes Web, Desktop · iOS · Android
dark global.bg.code.warning #d2cecf on #1f1504 11.54:1 passes Web, Desktop · iOS · Android

global.bg.code.highlighted on global.bg.level.1.default

The highlighted line background against the default code block (level 1). Measured only: the marker, not the tint, shows the state. Measured, no minimum. WCAG 1.4.1 Use of Color (A)WCAG 1.4.11 Non-text Contrast (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.1.default #eef1f7 on #f7f6f6 1.04:1 measured Web, Desktop · iOS · Android
dark global.bg.level.1.default #09191d on #212121 1.11:1 measured Web, Desktop · iOS · Android

global.bg.code.inserted on global.bg.level.1.default

The inserted line background against the default code block (level 1). Measured only: the marker, not the tint, shows the state. Measured, no minimum. WCAG 1.4.1 Use of Color (A)WCAG 1.4.11 Non-text Contrast (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.1.default #dbfae6 on #f7f6f6 1.03:1 measured Web, Desktop · iOS · Android
dark global.bg.level.1.default #011c16 on #212121 1.10:1 measured Web, Desktop · iOS · Android

global.bg.code.deleted on global.bg.level.1.default

The deleted line background against the default code block (level 1). Measured only: the marker, not the tint, shows the state. Measured, no minimum. WCAG 1.4.1 Use of Color (A)WCAG 1.4.11 Non-text Contrast (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.1.default #feecea on #f7f6f6 1.05:1 measured Web, Desktop · iOS · Android
dark global.bg.level.1.default #2b0b08 on #212121 1.12:1 measured Web, Desktop · iOS · Android

global.bg.code.error on global.bg.level.1.default

The error line background against the default code block (level 1). Measured only: the marker, not the tint, shows the state. Measured, no minimum. WCAG 1.4.1 Use of Color (A)WCAG 1.4.11 Non-text Contrast (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.1.default #feecea on #f7f6f6 1.05:1 measured Web, Desktop · iOS · Android
dark global.bg.level.1.default #2b0b08 on #212121 1.12:1 measured Web, Desktop · iOS · Android

global.bg.code.warning on global.bg.level.1.default

The warning line background against the default code block (level 1). Measured only: the marker, not the tint, shows the state. Measured, no minimum. WCAG 1.4.1 Use of Color (A)WCAG 1.4.11 Non-text Contrast (AA)

ModeBackgroundColorsRatioPlatforms
light global.bg.level.1.default #fff1c7 on #f7f6f6 1.04:1 measured Web, Desktop · iOS · Android
dark global.bg.level.1.default #1f1504 on #212121 1.11:1 measured Web, Desktop · iOS · Android

Accessibility

Target: WCAG 2.2 level AA. Every statement cites the trusted source it comes from; criteria beyond the target are adopted as extra quality.

Every platform

  • Every code color, comments, diff and link colors included, contrasts at least 4.5:1 with every surface level and sunken and with every line background, in every mode: code is text, whatever its category. WCAG 1.4.3 Contrast (Minimum) (AA)
  • Color is not the only way to tell the categories apart: highlighting adds no information that the code text does not already carry, so a reader who cannot see the colors misses nothing. WCAG 1.4.1 Use of Color (A)
  • A marked line never shows its state by color alone: a bar, + and -, x and ! mark it, and they survive forced colors mode, where the line backgrounds disappear. WCAG 1.4.1 Use of Color (A)

Web

WCAG success criteria

CriterionLevelUnderstanding
1.3.1 Info and Relationships A Understanding 1.3.1
1.4.1 Use of Color A Understanding 1.4.1
1.4.3 Contrast (Minimum) AA Understanding 1.4.3
1.4.11 Non-text Contrast AA Understanding 1.4.11

References

Changelog

  • 0.1.1 2026-10-22 — Fix, no decision changed: the CSS and HTML samples (cards.css, dropdown.html) no longer load the component styles from @quantum-ds/components, which publishes the specs only; they load the component styles the product implemented from the specs.
  • 0.1.0 2026-10-02 — Initial draft, decisions code-colors, code-colors-contrast, code-additions and shiki-theme. Owns the Figma library's global.text.code.* (keyword, variable, function, class-and-type, string, number, comment); five of them move to a passing step (light class-and-type, string, number; dark string, comment), the only divergences from the Figma library (pnpm tokens:figma-library). Adds, in tokens/additions/: global.text.code.inserted, deleted, changed, invalid, link, and the line backgrounds global.bg.code.highlighted, inserted, deleted, error, warning. New outputs web/shiki-theme.json (generated) and web/foundations/code.css (marked lines). Contrast, lowest over every surface level, sunken and line background, every platform (4.5:1 required, WCAG 1.4.3): light keyword 6.51:1, variable 5.82:1, function 5.85:1, class and type 4.90:1, string 6.43:1, number 5.67:1, comment 7.71:1, inserted 7.01:1, deleted and invalid 5.45:1, changed 7.31:1, link 5.16:1, plain code 17.00:1 (all lowest on the error line background); dark keyword 4.51:1, variable 5.59:1, function 5.94:1, class and type 7.25:1, string 5.78:1, number 5.73:1, comment 4.77:1, inserted 5.92:1, deleted and invalid 6.96:1, changed 5.35:1, link 9.61:1 (level 3), plain code 11.42:1. Measured only: line backgrounds against the level 1 block, light 1.03 to 1.05:1, dark 1.10 to 1.12:1 (the markers carry the state, WCAG 1.4.1).