The main button of your product is blue. The designer asked for it a bit darker, one developer copied the old value into another page, a third retouched a shade "by eye" for a banner: six months later you have three almost identical blues and nobody knows which one is the right one. A design system exists to prevent this drift, and it has three parts: named values (the tokens), components that use them, and rules about how everything changes over time, that is, governance.
The part that is hardest to understand from the outside is the last one, because it does not show in the code. A token with a stable name is a commitment to whoever uses it: if you delete it, somebody breaks; if you change its value, somebody sees a different interface. Here you build, on a test project, a small set of tokens in the format of the W3C Design Tokens Community Group, turn it into CSS variables with Style Dictionary, add a contrast check that makes publishing fail, and a tool that suggests the version bump. The examples are on test files built for the occasion.
What a token is, in the format being standardized
A design token is a named value that represents a design choice: a color, a distance, a font size. The W3C Design Tokens Community Group (DTCG) published the "Design Tokens Format Module 2025.10" as a Final Community Group Report on 28 October 2025. Note the type of document: it is a community group report, not a W3C Recommendation, and it describes a file format for exchanging tokens between different tools.
In the format, a token is an object with the $value property, and the type is declared with $type, possibly inherited from the group that contains it. A color is an object with colorSpace and components (the specification's examples also show alpha and hex), a dimension is an object with value and unit. A token can refer to another with the curly-brace syntax, for example {color.brand}: the reference points to a token, not to a group. The specification also provides $deprecated, which is true or a string with the explanation: you will need it for renames. The following file is my test project.
{
"color": {
"$type": "color",
"brand": { "$value": { "colorSpace": "srgb", "components": [0.043, 0.361, 0.678], "hex": "#0b5cad" } },
"link": { "$value": "{color.brand}" },
"surface": { "$value": { "colorSpace": "srgb", "components": [1, 1, 1], "hex": "#ffffff" } },
"text": {
"base": { "$value": { "colorSpace": "srgb", "components": [0.106, 0.106, 0.122], "hex": "#1b1b1f" } },
"muted": { "$value": { "colorSpace": "srgb", "components": [0.541, 0.561, 0.596], "hex": "#8a8f98" } }
}
},
"space": {
"$type": "dimension",
"sm": { "$value": { "value": 8, "unit": "px" } },
"md": { "$value": { "value": 16, "unit": "px" } }
}
}
The file contains two structural choices. The color.link token does not repeat the brand value but calls it up, so a change to brand propagates to all the references. And I deliberately left color.text.muted with a gray, #8a8f98, that looks clean to the eye: the contrast check will reject it further down. The sRGB values have both the components and the hex, as in the specification's examples; my contrast check, later on, reads precisely the hex.
From tokens to CSS variables
Style Dictionary is an open source tool that turns tokens into CSS variables and into formats for other platforms; the current version on npm, as of 13 November 2026, is 5.8.0. The documentation declares first-class support for the DTCG format since version 4 and warns that the 2025.10 format is not yet fully supported in version 5. In the test with my file the output was correct, but that is not a guarantee: for a real project, verify the combination of versions you use.
The configuration in build.mjs has a single platform: transformGroup: 'css' applies the transformations designed for CSS (in my test the colors came out as #rrggbb and the dimensions as 8px), and the css/variables format writes the custom properties inside :root. The buildPath path says where to write the file. The variable name derives from the token's path: color.text.base becomes --color-text-base.
import StyleDictionary from 'style-dictionary';
const sd = new StyleDictionary({
source: [process.argv[2] ?? 'tokens.json'],
platforms: {
css: {
transformGroup: 'css',
buildPath: 'build/',
files: [{ destination: 'tokens.css', format: 'css/variables' }],
},
},
});
await sd.buildAllPlatforms();
// Output:
// /**
// * Do not edit directly, this file was auto-generated.
// */
//
// :root {
// --color-brand: #0b5cad;
// --color-link: #0b5cad;
// --color-surface: #ffffff;
// --color-text-base: #1b1b1f;
// --color-text-muted: #8a8f98;
// --space-sm: 8px;
// --space-md: 16px;
// }
Note that the color.link token, a reference, was resolved to #0b5cad, and that the dimension { "value": 8, "unit": "px" } became 8px. The variables are the point of contact with the components: a component writes padding: var(--space-sm) and does not know the value. A change of token requires running the script again, not a search through the code.
The gate the design system can give for free: contrast
If the design system owns the colors, it can verify them. The check-tokens.mjs script reads the tokens, resolves the references with hexOf and uses the contrastRatio function developed in the article on accessibility (the contrast.mjs file is the same). The pairs to check are written in the script with the 4.5:1 threshold of WCAG criterion 1.4.3 for normal text; at the end it exits with code 1 if at least one pair fails, so a pipeline can block publishing.
import { readFileSync } from 'node:fs';
import { contrastRatio } from './contrast.mjs';
const tokens = JSON.parse(readFileSync(process.argv[2], 'utf8'));
const lookup = (path) => path.split('.').reduce((node, key) => node?.[key], tokens);
function hexOf(path, seen = new Set()) {
if (seen.has(path)) throw new Error(`circular reference: ${path}`);
const token = lookup(path);
if (!token || token.$value === undefined) throw new Error(`token does not exist: ${path}`);
const v = token.$value;
if (typeof v === 'string' && v.startsWith('{')) return hexOf(v.slice(1, -1), seen.add(path));
return typeof v === 'string' ? v : v.hex;
}
// pairs that the test project really uses, with the WCAG 1.4.3 threshold (normal text)
const pairs = [
['color.text.base', 'color.surface'],
['color.text.muted', 'color.surface'],
['color.link', 'color.surface'],
];
let failed = 0;
for (const [fg, bg] of pairs) {
const ratio = contrastRatio(hexOf(fg), hexOf(bg));
const ok = ratio >= 4.5;
if (!ok) failed++;
console.log(`${ok ? 'OK ' : 'FAILED'} ${fg} on ${bg}: ${ratio.toFixed(2)}:1`);
}
process.exit(failed === 0 ? 0 : 1);
// Output:
// OK color.text.base on color.surface: 17.17:1
// FAILED color.text.muted on color.surface: 3.25:1
// OK color.link on color.surface: 6.67:1
// exit=1
// OK color.text.base on color.surface: 17.17:1
// OK color.text.muted on color.surface: 4.83:1
// OK color.link on color.surface: 6.67:1
// exit=0
The first run, on the file from the previous section, rejects color.text.muted: 3.25:1 against the 4.5:1 required, and the process exits with code 1 (the exit= line is printed by the shell, not by the script). The second, on tokens-v2.json, where the gray was darkened to #6b7280, passes with 4.83:1 and code 0. The limit is clear: the check sees only the pairs you list, and does not know where a color will end up. A text token used on a background you have not declared is not measured.
Versions: what an incompatible change is
Semantic Versioning 2.0.0 numbers versions as MAJOR.MINOR.PATCH: you increment MAJOR for incompatible API changes, MINOR when you add functionality in a backward compatible manner, PATCH for backward compatible bug fixes. The premise, says semver.org, is that the software declares a public API, and that this API is clear and precise. For a design system the question to settle is therefore: what is your API? A reasonable answer is that it includes the names of the tokens and the names and inputs of the components, because they are what the consumers' code cites.
With this definition, removing or renaming a token is a MAJOR change, adding one is MINOR, and changing the value of an existing token is the gray case: if it fixes an error it is a PATCH, if it changes the look of all the consumers' interfaces it can count as an incompatible change. This classification is a convention that you must adopt in the team, not a SemVer rule. The diff-tokens.mjs script compares two versions of the files and reports only what can be established mechanically; I run it on three test files, tokens.json, tokens-v2.json and tokens-v3.json.
import { readFileSync } from 'node:fs';
// Flattens the tokens into a map path -> { value, deprecated }
function flatten(node, prefix = '', out = new Map()) {
for (const [key, value] of Object.entries(node)) {
if (key.startsWith('$')) continue;
const path = prefix ? `${prefix}.${key}` : key;
if (value && typeof value === 'object' && '$value' in value) {
out.set(path, { value: JSON.stringify(value.$value), deprecated: Boolean(value.$deprecated) });
} else if (value && typeof value === 'object') {
flatten(value, path, out);
}
}
return out;
}
const before = flatten(JSON.parse(readFileSync(process.argv[2], 'utf8')));
const after = flatten(JSON.parse(readFileSync(process.argv[3], 'utf8')));
const removed = [...before.keys()].filter((k) => !after.has(k));
const added = [...after.keys()].filter((k) => !before.has(k));
const deprecated = [...after.keys()].filter((k) => before.has(k) && after.get(k).deprecated && !before.get(k).deprecated);
const changed = [...before.keys()].filter((k) => after.has(k) && after.get(k).value !== before.get(k).value);
for (const k of removed) console.log(`removed ${k}`);
for (const k of added) console.log(`added ${k}`);
for (const k of deprecated) console.log(`deprecated ${k}`);
for (const k of changed) console.log(`new value ${k}`);
let minimum = 'no change';
if (added.length > 0 || deprecated.length > 0) minimum = 'at least MINOR';
if (removed.length > 0) minimum = 'MAJOR';
console.log(`certain version bump: ${minimum}`);
if (changed.length > 0) console.log(`changed values to judge by hand: ${changed.length}`);
// Output:
// added space.base
// added space.lg
// deprecated space.md
// new value color.text.muted
// certain version bump: at least MINOR
// changed values to judge by hand: 1
//
// removed space.md
// certain version bump: MAJOR
The tokens-v2.json file makes a rename in two steps: it adds space.base and marks space.md with $deprecated, leaving its value. The first comparison classifies it as "at least MINOR", and reports that one value, that of color.text.muted, has changed and must be judged by hand. In tokens-v3.json space.md disappears, and the second comparison classifies it MAJOR: a removal breaks whoever still uses the old name. The semver.org FAQ describes the path that avoids the abrupt jump: update the documentation, issue a MINOR release in which the functionality is marked as deprecated, and remove it in a later MAJOR release, after at least one MINOR release containing the deprecation. The DTCG format offers the right tool, $deprecated, and the script recognizes it.
Component levels and documentation
Brad Frost described in his article of 10 June 2013 a five-level model, borrowed from chemistry: atoms are HTML tags such as labels, inputs and buttons, and can include more abstract elements such as color palettes and fonts; molecules are groups of atoms bonded together, for example a search form; organisms are groups of molecules joined to form a distinct section of the interface; then come templates and pages. Tokens sit at the level of atoms, and components rise from there.
For documentation, Storybook defines a story as capturing the rendered state of a UI component, described by an object with annotations and arguments. The story file lives alongside the component and does not end up in the production bundle. The advantage for a design system is that the states (enabled, disabled, error) are viewed and discussed in one place, and stay close to the code that produces them. I did not include a Storybook listing because it requires a project with its own framework, which was not run here.
Governance: decisions to make, not numbers to copy
Governance is the set of answers to four questions, which each team must write down with its own numbers. There is no "right" trial period or notice period in absolute terms: it depends on how many consumers you have and how much it costs them to update.
- Who decides that a token or a component enters, changes or leaves: one person, a small group, or an open review.
- How a new component gets in: how many real interfaces must use it before it becomes part of the system, and who verifies it.
- How it leaves: for how long it stays deprecated, and how consumers find out, for example with a note in the releases and a warning at the time of use.
- How you communicate: a readable list of changes, and a place where the teams that use the system can discuss requests.
What the four answers have in common is the cost to those who consume the system. A system in which everyone can add things becomes a collection of variants, a system in which nobody can add without a long process gets bypassed with local copies; the compromise lies in the middle, and it is a decision to revisit when the size and frequency of requests change. You measure the outcome of your work like this: how many colors and distances not coming from the tokens appear in the code, and how often a token change requires fixes to consumers.
Frequently asked questions
How many tokens do I need to start?
Those you already repeat: the text, background and action colors, and the scale of distances. The test project has seven tokens and that is enough to see the whole cycle, from definition to contrast check and to comparison between versions.
Is the DTCG format a W3C standard?
No, not in the sense of a Recommendation. The document "Design Tokens Format Module 2025.10" is a Final Community Group Report of 28 October 2025, published by the Design Tokens Community Group under the W3C Community Final Specification Agreement.
Is renaming a token an incompatible change?
For those who use the old name, yes: the name is part of the system's API. With Semantic Versioning the safe rename requires adding the new name in a MINOR version, deprecating the old one (in DTCG with $deprecated) and removing it in a later MAJOR.
What you can do now
You can write tokens in the DTCG 2025.10 format, resolve references, turn them into CSS variables with Style Dictionary, and you know that support for the latest format is still a work in progress in that tool. You can make a publication fail when a color does not meet the minimum contrast, and you know that the check only covers the declared pairs. You know which token changes can be classified mechanically, such as a removal or a deprecation, and which require a decision, such as a changed value, and you have four questions that your team must answer in writing in order to do governance. To try it, start from a real CSS page, extract the colors that appear in it and count how many are almost identical.
The previous article in the series deals with WCAG accessibility, from which the contrast check comes; Nielsen's heuristics explain why internal consistency (the fourth) matters. The next step is prototyping from Figma to code, and after it usability testing. The index is on the series page.
Sources
- Design Tokens Community Group, Design Tokens Format Module 2025.10 - Final Community Group Report status (28 October 2025),
$value,$type,$deprecated, references, shape of colors and dimensions; read in the parts cited, consulted on 2026-11-13 - Style Dictionary, DTCG - support since v4 and the note that the 2025.10 format is not yet fully supported in v5; version 5.8.0 read from the npm registry (
npm view style-dictionary version), consulted on 2026-11-13 - Semantic Versioning 2.0.0 - definition of MAJOR, MINOR and PATCH, requirement to declare a public API, deprecation path; read in the parts cited, consulted on 2026-11-13
- Brad Frost, Atomic Design - article of 10 June 2013, levels atoms, molecules, organisms, templates, pages; read in the parts cited, consulted on 2026-11-13
- Storybook, Writing stories - definition of a story and position of the file alongside the component; read in the parts cited, consulted on 2026-11-13
- Measurements made by me: the four listings, run with Node 24.11 and Style Dictionary 5.8.0 on a test project, each twice with identical output; contrast uses the WCAG 2.2 formula and the module from the article on accessibility
Commenti
Caricamento commenti...
Sign in to comment