Skip to content

Search

Articles, tools, solutions and knowledge base guides

Start typing to search across articles, tools and apps.

Design Systems: How to Build and Maintain a Scalable Design System

A design system connects visual decisions, code and collaboration. Follow a token into a button shared by several products, then verify its contract and plan how to release changes.

Published Written by Reading time 8 min read
On this page Contents: quick navigation between sections

What is a design system?

A component library provides code and a style guide describes appearance. A design system also includes usage rules, ownership, documentation and a change process. There is no need to build a catalogue of every conceivable control upfront.

Collect three real screens from different products. Identify repeated decisions such as action colors, spacing, forms and messages. Start with the most repeated pattern, agree on its contract and remove duplication only after the replacement works.

How should design tokens be organized?

tokens.json

{
  "space": {
    "$type": "dimension",
    "medium": {
      "$value": { "value": 16, "unit": "px" }
    }
  },
  "component": {
    "button": {
      "paddingInline": {
        "$type": "dimension",
        "$value": "{space.medium}"
      }
    }
  }
}

Related articles and tools

Separate primitive values (palette and spacing scales), semantic tokens (action color) and component tokens (button padding). Changing the palette then need not modify every component. [1]

DTCG 2025.10 is a stable Community Group report, not a W3C Recommendation. The sample dimension token contains a value and unit; an alias refers to another token path. This is an exchange-format fragment, not a complete CSS generator. Detect missing and cyclic references during the build. [1]

Themes and the CSS cascade

tokens.css

:root {
  --space-medium: 16px;
  --button-padding-inline: var(--space-medium);
  --control-min-size: 44px;
  --radius-control: 8px;
  --palette-white: #ffffff;
  --palette-ink: #172033;
  --palette-blue: #1747a6;
  --palette-blue-hover: #12377e;
  --palette-blue-light: #a8c7ff;
  --palette-blue-light-hover: #c5d9ff;
}

:root,
[data-theme="light"] {
  color-scheme: light;
  --color-surface: var(--palette-white);
  --color-text: var(--palette-ink);
  --color-action: var(--palette-blue);
  --color-action-hover: var(--palette-blue-hover);
  --color-on-action: var(--palette-white);
  --color-focus: var(--palette-blue);
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-surface: var(--palette-ink);
  --color-text: var(--palette-white);
  --color-action: var(--palette-blue-light);
  --color-action-hover: var(--palette-blue-light-hover);
  --color-on-action: var(--palette-ink);
  --color-focus: var(--palette-blue-light);
}

Related articles and tools

Define semantic colors at each theme boundary. Components consume roles rather than picking shades based on theme names. The example places light and dark regions side by side; an explicit data-theme attribute selects the theme, without automatically following the system preference.

The CSS is a manually mapped token example. In production, generate artifacts from one source and review their changes in CI. The color-scheme property informs the browser about native controls; it does not automatically recolor author-defined components. [2]

Component contracts and states

index.html

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Button contract</title>
    <link rel="stylesheet" href="/en/tokens.css" />
    <link rel="stylesheet" href="/en/button.css" />
  </head>
  <body>
    <main class="gallery">
      <h1>Button states</h1>
      <section class="surface" data-theme="light">
        <h2>Light theme</h2>
        <button class="button" type="button">Save settings</button>
        <button class="button" type="button" disabled>Unavailable</button>
      </section>
      <section class="surface" data-theme="dark">
        <h2>Dark theme</h2>
        <button class="button" type="button">Save settings</button>
        <button class="button" type="button" disabled>Unavailable</button>
      </section>
    </main>
  </body>
</html>

button.css

body {
  margin: 0;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: system-ui, sans-serif;
}

.gallery {
  display: grid;
  gap: var(--space-medium);
  padding: var(--space-medium);
}

.surface {
  display: grid;
  justify-items: start;
  gap: var(--space-medium);
  padding: var(--space-medium);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid currentColor;
  border-radius: var(--radius-control);
}

.button {
  box-sizing: border-box;
  max-inline-size: 100%;
  min-block-size: var(--control-min-size);
  min-inline-size: var(--control-min-size);
  padding: 8px var(--button-padding-inline);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--color-action);
  color: var(--color-on-action);
  font: inherit;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.button:not(:disabled):hover {
  background: var(--color-action-hover);
}

.button:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

@media (forced-colors: active) {
  .button {
    border-color: ButtonText;
  }

  .button:disabled {
    border-color: GrayText;
  }

  .button:focus-visible {
    outline-color: Highlight;
  }
}

Related articles and tools

A button needs a defined type, accessible name, variants, disabled state and keyboard behavior. A native button supplies semantics and keyboard activation; type button prevents accidental form submission. Disabled differs from aria-disabled, which does not itself prevent activation. [6][7]

The gallery demonstrates default, hover, focus-visible and disabled states in two themes. It illustrates appearance rather than saving settings. Specify loading, error and long-label behavior separately when the component participates in a real workflow. Do not add a variant without a concrete use case.

Accessibility as part of the contract

WCAG 2.2 AA requires at least 4.5:1 contrast for ordinary text and 3:1 for large text, subject to exceptions. Essential visual information about controls and states falls under 1.4.11. The sample's 44 px target is a design choice, not the general AA minimum: 2.5.8 concerns 24 by 24 CSS px with exceptions. [3]

Do not remove a focus outline without a replacement. Check Tab, Enter, Space, zoom, long translations and forced-colors. Inactive controls are exempt from the specified contrast requirements, but keep labels legible when users need them. A component alone cannot guarantee page-level conformance.

Testing tokens and components

contrast.ts

type Rgb = readonly [number, number, number];

function linearChannel(channel: number): number {
  const normalized = channel / 255;

  if (normalized <= 0.04045) {
    return normalized / 12.92;
  }

  return ((normalized + 0.055) / 1.055) ** 2.4;
}

function luminance([red, green, blue]: Rgb): number {
  const r = linearChannel(red);
  const g = linearChannel(green);
  const b = linearChannel(blue);

  return 0.2126 * r + 0.7152 * g + 0.0722 * b;
}

function parseHex(hex: string): Rgb {
  if (hex.length !== 7) {
    throw new RangeError("Expected a six-digit hex color.");
  }

  if (!/^#[0-9a-f]{6}$/i.test(hex)) {
    throw new RangeError("Expected a six-digit hex color.");
  }

  return [
    Number.parseInt(hex.slice(1, 3), 16),
    Number.parseInt(hex.slice(3, 5), 16),
    Number.parseInt(hex.slice(5, 7), 16),
  ];
}

export function contrastRatio(first: string, second: string): number {
  const a = luminance(parseHex(first));
  const b = luminance(parseHex(second));
  const lighter = Math.max(a, b);
  const darker = Math.min(a, b);

  return (lighter + 0.05) / (darker + 0.05);
}

contrast.test.mjs

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { test } from "node:test";
import { contrastRatio } from "./dist/contrast.js";

const stylesheet = readFileSync(
  new URL("tokens.css", import.meta.url),
  "utf8",
);

function paletteColor(name) {
  const pattern = new RegExp(`--palette-${name}: (#[0-9a-f]{6});`, "i");
  const match = stylesheet.match(pattern);

  if (!match) {
    throw new Error(`Missing palette color: ${name}`);
  }

  return match[1];
}

const pairs = [
  ["white", "ink", 4.5],
  ["white", "blue", 4.5],
  ["white", "blue-hover", 4.5],
  ["ink", "blue-light", 4.5],
  ["ink", "blue-light-hover", 4.5],
  ["white", "blue", 3],
  ["ink", "blue-light", 3],
];

for (const [foreground, background, minimum] of pairs) {
  test(`${foreground} / ${background}: ${minimum}:1`, () => {
    // Given
    const first = paletteColor(foreground);
    const second = paletteColor(background);

    // When
    const ratio = contrastRatio(first, second);

    // Then
    assert.ok(ratio >= minimum, `Measured ${ratio}`);
  });
}

test("equal colors have a ratio of 1", () => {
  assert.equal(contrastRatio("#ffffff", "#ffffff"), 1);
});

test("black and white have a ratio of 21", () => {
  assert.equal(contrastRatio("#000000", "#ffffff"), 21);
});

test("invalid color strings are rejected", () => {
  for (const invalid of ["#fff", "#zzzzzz", "#123456\n"]) {
    assert.throws(() => contrastRatio(invalid, "#ffffff"), RangeError);
  }
});

For opaque sRGB colors written as #RRGGBB, calculate relative luminance and contrast without rounding before comparing with a threshold. The function rejects other formats; it does not analyze gradients, transparency or the actual cascade. [3]

Node.js tests check palette pairs assigned to both themes, identical colors, black and white and invalid inputs. Given-When-Then separates setup, action and outcome. Supplement automation with computed-style checks, keyboard and screen-reader checks and screenshots in a controlled environment. [4]

Documentation and versioning

Related articles and tools

Document intended usage, the contract, good and bad examples and a state matrix covering both themes, focus, disabled, narrow screens and long labels. Storybook can document and test these scenarios but does not replace testing inside an application. [4]

Define the public API to include documented tokens and behaviors. Under SemVer, an incompatible public API change requires a major release after 1.0.0. Removing a consumed token can be such a change; provide an alias, deprecation period and migration instructions. [5]

Adoption across products

Separate a token package and optional platform-specific component packages. Do not force identical HTML on web and native apps. Share token semantics while respecting platform requirements. Establish ownership, a contribution process and criteria for accepting changes.

Pilot in one workflow with known risks. Measure version adoption, local overrides and defects after upgrades rather than the number of components alone. If a regression occurs, pause rollout or revert to a compatible version. The related articles and tools below expand on cascade, accessibility and token design.

Start with actual duplication, define public contracts and verify them whenever they change. A useful system enables adoption without sacrificing functionality or accessibility.

Tools for this topic

Design Systems Design Tokens CSS Components Accessibility WCAG Storybook Semantic Versioning DTCG

Frequently asked questions

Is Figma required?

No. You need a shared contract and change process; a design tool is one possible implementation.

Is a token a CSS variable?

No. A token names a design decision; a CSS variable is one way to deliver it to a browser. [1]

Is 44 px mandatory at AA?

No. Criterion 2.5.8 concerns 24 by 24 CSS px and includes exceptions. [3]

Does a contrast test guarantee WCAG conformance?

No. It does not cover keyboard access, document structure or all rendered colors.

When is a major release needed?

When a stable public API changes incompatibly, including removal of a documented token. [5]

How can I start without rewriting the app?

Extract a frequent pattern, adopt it in one workflow, check regressions and migrate incrementally.

Sources and references

  1. DTCG: Design Tokens Format Module 2025.10↩1↩2↩3
  2. MDN: color-scheme↩
  3. W3C: WCAG 2.2↩1↩2↩3↩4
  4. Storybook: UI testing↩1↩2
  5. Semantic Versioning 2.0.0↩1↩2↩3
  6. MDN: button↩
  7. MDN: aria-disabled↩

Was this helpful?

Get new articles by email

One short email per new Learning article. No spam, unsubscribe in one click.

We only use your email to send new articles. No third-party sharing.

Back to Learning