01Hardcoded values are the tax that compounds

A hex code typed directly into a component is fine the first time. It's fine the tenth time too. Somewhere past that, a rebrand or a second tenant's theme requires finding every one of those values by hand, and inevitably missing a few. That is the classic sign of a design system that never had a token layer underneath it.

Tokens aren't about having fewer colors. They're about giving every value a name tied to its role, so changing the role changes every place it's used, automatically.

02Three layers, each with one job

  1. 01

    Primitive tokens: raw values

    blue-500, space-4, radius-lg: the actual numbers and colors, with no opinion about where they're used. This is the only layer that changes per brand.

  2. 02

    Semantic tokens: role, not value

    color-action-primary points at blue-500. Components reference the semantic name, never the primitive directly. That indirection is what makes theming possible.

  3. 03

    Component tokens: local overrides

    button-primary-bg maps to color-action-primary by default but can diverge for one component without touching the semantic layer everything else depends on.

  4. 04

    A theme is a value swap, not a rewrite

    Dark mode, a white-label brand and a high-contrast mode are each a different primitive layer pointed at the same semantic names. Components never know which theme is active.

  5. 05

    Name by intent, not appearance

    color-danger, not color-red. A future theme might express danger as orange, and the name has to survive the palette changing under it.

  6. 06

    Enforce it with lint, not memory

    A stylelint rule banning raw hex/px values outside the token file turns "please use tokens" from a code-review nag into something CI catches automatically.

03Multi-brand is the real stress test

Dark mode alone can hide a weak token architecture, because two themes can be brute-forced with enough CSS overrides. A third brand, with its own primary color, radius scale and typography, is where the semantic layer either holds or the cracks show: components that assumed "primary is blue" somewhere in their markup, spacing that was eyeballed instead of tokenized, icons baked with a fixed color. Design for the third theme even when only shipping two.

04Tokens as SCSS maps and CSS variables

In an Angular app I keep primitives as a Sass map (compile-time only), expose semantic tokens as CSS custom properties on :root, and let components define their own component tokens on :host.

Swapping a theme or a tenant brand then means redefining the semantic layer in one selector, while every component's SCSS stays untouched. Since CSS variables cascade through Angular's emulated encapsulation, no ::ng-deep is needed.

styles/themes/_light.scss + button.component.scss
@use 'sass:map';
@use '../abstracts/primitives' as p;

// semantic layer — the only thing a theme or brand redefines
:root {
  --color-surface: #{map.get(p.$colors, stone-50)};
  --color-text: #{map.get(p.$colors, stone-900)};
  --color-action: #{map.get(p.$colors, orange-600)};
}

// button.component.scss — component layer
:host {
  --button-bg: var(--color-action);
  --button-fg: var(--color-surface);
}

.btn {
  background: var(--button-bg);
  color: var(--button-fg);
}

The takeaway

Primitive tokens hold raw values, semantic tokens hold intent, and components reference only the semantic layer. That indirection is the entire trick — a new theme becomes a new set of values, not a new set of components.

Written by Jaymin MahetaSenior UI/UX Developer turning Figma designs into fast, accessible enterprise apps in Angular and React.
About me →