ApiaryActive
Try: pause · settings · learn · wipe
← Community / Reading Room
DT
knowledge · 15 min read

Design Token Management

In the digital age, a design system is the backbone that keeps a product’s visual language coherent across every screen, device, and interaction. At the heart…

By the Apiary team


Introduction

In the digital age, a design system is the backbone that keeps a product’s visual language coherent across every screen, device, and interaction. At the heart of a design system lie design tokens—the smallest, reusable pieces of a UI’s visual language, expressed as data (e.g., a hex color, a spacing value, a font weight). When these tokens are managed correctly, they become a single source of truth that powers designers, developers, and even autonomous AI agents alike.

Why does this matter for a platform like Apiary? First, consistency directly influences user trust. A dashboard that monitors bee‑colony health can’t afford visual glitches that distract from critical data. Second, token‑driven workflows dramatically reduce the time spent on hand‑coding UI values: a 2023 State of Design Systems survey reported that teams using a token pipeline saved 30 % of front‑end effort on average. Finally, as Apiary’s AI agents begin to generate custom visualizations for field researchers, a well‑structured token catalog gives those agents a reliable vocabulary to speak the language of the UI without breaking the brand.

In this pillar article we’ll walk through the entire lifecycle of design token management—definition, platform mapping, and versioning—using Style Dictionary, the industry‑standard open‑source tool that turns tokens into code for any platform. By the end, you’ll have a concrete, production‑ready roadmap you can apply to your own projects, whether you’re building a bee‑conservation dashboard, a fintech app, or a fleet of self‑governing AI agents.


What Are Design Tokens?

Design tokens are named entities that store visual design decisions. Think of them as variables in a programming language, but for design. A token can represent a primary brand color, a line‑height, a shadow, an animation timing, or even a semantic concept like “error state”.

Token nameValueTypeExample usage
color.brand.primary#FFB400ColorButtons, icons
spacing.base8Number (px)Grid gutters
font.size.heading132FontSize (pt)H1 headings
border.radius.card4Radius (dp)Card corners
animation.duration.fadeIn250msDurationModal entrance

A few concrete benefits:

  • Scalability – A single change (e.g., updating color.brand.primary) propagates to all UI instances.
  • Cross‑platform fidelity – Tokens can be transformed to match the syntax of iOS (UIColor), Android (@color), CSS (var(--…)), or Flutter (Color).
  • Automation‑ready – CI pipelines can regenerate assets whenever a token changes, guaranteeing that the codebase never drifts from the design source.

The concept isn’t new; it was first formalized by Salesforce’s Lightning Design System in 2016, and the Design Tokens Community Group now maintains a vendor‑neutral specification (see the official W3C Design Tokens draft). However, the real power emerges only when you couple the specification with a robust tooling pipeline—enter Style Dictionary.


The Anatomy of a Token

Before we let Style Dictionary do its magic, we must understand the internal structure of a token file. Most teams store tokens in JSON or YAML because these formats are language‑agnostic and easy to version. A typical token object includes the following fields:

{
  "global": {
    "color": {
      "brand": {
        "primary": {
          "value": "#FFB400",
          "type": "color",
          "description": "Primary brand color used for call‑to‑action elements."
        },
        "secondary": {
          "value": "#006837",
          "type": "color",
          "description": "Secondary brand color for supporting UI."
        }
      }
    },
    "spacing": {
      "base": {
        "value": "8",
        "type": "dimension",
        "unit": "px"
      },
      "large": {
        "value": "24",
        "type": "dimension",
        "unit": "px"
      }
    }
  }
}
  • value – The raw data (hex, number, etc.).
  • type – Helps tools apply the right conversion (e.g., colorUIColor).
  • unit – Optional but useful for dimensions.
  • description – Human‑readable context; essential for onboarding new designers or AI agents that need to explain why a token exists.

Naming Conventions

A disciplined naming scheme is the linchpin for discoverability. The BEM‑like hierarchical pattern (category.subcategory.name) is widely adopted because it mirrors the way designers think about layers. For instance, color.brand.primary clearly signals a brand‑level color, whereas color.neutral.100 would belong to a neutral palette.

Best practice: keep token names under 30 characters and lower‑case, with words separated by dots. This format works consistently across all target platforms, avoiding the need for platform‑specific renaming later on.


Style Dictionary Overview

Style Dictionary is a Node.js library that reads token files and outputs them into any format you need. It was created by Amazon in 2017 to solve the exact problem of distributing a unified token set across Web, iOS, Android, and native apps. As of June 2024, Style Dictionary boasts 13.8k GitHub stars, 350+ contributors, and is used by enterprises such as Airbnb, Shopify, and IBM.

Core Concepts

ConceptWhat It Does
SourceThe folder (or glob) where token files live.
TransformA function that converts a raw token value into a platform‑specific representation (e.g., #FFB400UIColor(red:1.0, green:0.71, blue:0.0, alpha:1.0)).
FormatThe final file template (e.g., CSS variables, SCSS mixins, JSON).
PlatformA grouping of transforms + formats that target a specific runtime (web, iOS, Android, etc.).
BuildThe process that runs all platforms, emitting files to the output/ directory.

Example Build File (build.js)

const StyleDictionary = require('style-dictionary');

// Register a custom transform for Flutter colors
StyleDictionary.registerTransform({
  name: 'color/flutter',
  type: 'value',
  matcher: token => token.type === 'color',
  transformer: token => {
    const hex = token.value.replace('#', '');
    const r = parseInt(hex.slice(0, 2), 16) / 255;
    const g = parseInt(hex.slice(2, 4), 16) / 255;
    const b = parseInt(hex.slice(4, 6), 16) / 255;
    return `Color.fromRGBO(${r*255}, ${g*255}, ${b*255}, 1)`;
  }
});

module.exports = StyleDictionary.extend({
  source: ['tokens/**/*.json'],
  platforms: {
    web: {
      transformGroup: 'css',
      buildPath: 'dist/web/',
      files: [{ destination: 'variables.css', format: 'css/variables' }]
    },
    ios: {
      transformGroup: 'ios',
      transforms: ['color/ios', 'size/ios'],
      buildPath: 'dist/ios/',
      files: [{ destination: 'Colors.h', format: 'ios/colors.h' }]
    },
    flutter: {
      transformGroup: 'js',
      transforms: ['color/flutter'],
      buildPath: 'dist/flutter/',
      files: [{ destination: 'colors.dart', format: 'flutter/colors' }]
    }
  }
}).buildAllPlatforms();

Running node build.js generates a CSS file, an iOS header, and a Flutter Dart file—all from the same source tokens. The build typically finishes in under 300 ms for a token set of 1,200 entries on a modern laptop (Intel i7‑12700H), which makes it practical for integration into CI pipelines.


Mapping Tokens to Platforms

A token set is only as useful as the platforms that consume it. Style Dictionary provides transform groups that map raw token values to the syntax expected by each target environment. Below we’ll walk through three common platforms: Web (CSS), iOS (Swift/Objective‑C), and Flutter (Dart).

1. Web – CSS Variables

Web browsers now support native CSS custom properties (var(--…)). Style Dictionary’s default css/variables format emits a file like:

:root {
  --color-brand-primary: #FFB400;
  --spacing-base: 8px;
  --font-size-heading1: 32px;
}

Developers can then use these variables directly in their stylesheets, guaranteeing that the UI always reflects the latest token values. In practice, teams report up to 15 % fewer CSS overrides after adopting token‑driven variables, because developers no longer need to duplicate color definitions across components.

2. iOS – Swift UIColor

For native iOS apps, tokens are transformed into UIColor extensions:

import UIKit

extension UIColor {
  static let brandPrimary = UIColor(red: 1.0, green: 0.71, blue: 0.0, alpha: 1.0)
  static let spacingBase = CGFloat(8.0) // used for layout constants
}

The color/ios transform automatically normalizes the hex value to the 0‑1 range required by UIColor. Moreover, because the generated file is type‑safe, Xcode will flag any misuse at compile time—a safety net that is especially valuable when AI agents generate UI code on the fly.

3. Flutter – Dart Color

Flutter’s Color class expects an integer ARGB value. A custom transform (color/flutter) produces:

import 'package:flutter/material.dart';

class AppColors {
  static const Color brandPrimary = Color(0xFFFFB400);
}

Note the leading FF for full opacity. By encapsulating platform‑specific quirks inside transforms, you keep the token source clean and maintainable.

Mapping Complex Tokens

Tokens aren’t limited to simple primitives. Some design decisions involve composite objects, such as a shadow token:

{
  "shadow.card": {
    "value": {
      "x": "0",
      "y": "2",
      "blur": "4",
      "spread": "0",
      "color": "rgba(0,0,0,0.15)"
    },
    "type": "shadow",
    "description": "Card elevation shadow."
  }
}

Style Dictionary can output this for Web as:

--shadow-card: 0 2px 4px 0 rgba(0,0,0,0.15);

For iOS, the same token becomes a UIShadow struct (via a custom format), and for Android it becomes an XML <item> inside a shape drawable. This demonstrates that platform mapping is not a one‑size‑fits‑all; each platform may need a different representation, and Style Dictionary’s extensible architecture lets you tailor each case.


Versioning Strategies

When a token set evolves, you need a disciplined versioning approach to avoid breaking downstream applications. The most widely adopted methodology is Semantic Versioning (SemVer): MAJOR.MINOR.PATCH. Below we outline how to apply SemVer to a token library, and how to automate release workflows.

1. Defining Release Types

ChangeSemantic ImpactExample
PatchBackward‑compatible value change (e.g., spacing.base from 8 to 8.5 when the design system tolerates sub‑pixel values).Increment 1.2.3 → 1.2.4.
MinorAdditive change, such as a new token (color.brand.accent) that does not affect existing token consumers.Increment 1.2.3 → 1.3.0.
MajorBreaking change, like renaming a token (color.brand.primarycolor.brand.main) or altering its type (color → gradient).Increment 1.2.3 → 2.0.0.

2. Changelog Automation

A well‑structured CHANGELOG.md is vital for developers and AI agents that rely on the token library. Tools like standard-version or semantic-release can parse commit messages (following the Conventional Commits spec) to automatically generate a changelog. Example entry:

## 2.0.0 – 2026‑04‑12
### Breaking Changes
- Renamed `color.brand.primary` → `color.brand.main` (see [[token-renaming-guidelines]]).
- Updated `shadow.card` type from `shadow` to `elevation`, requiring a new transform for Android.

### Added
- New token `color.brand.accent` for promotional banners.

3. CI/CD Integration

A typical CI pipeline for token publishing might look like:

name: Token Release

on:
  push:
    branches: [main]

jobs:
  build-and-publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install dependencies
        run: npm ci
      - name: Build token bundles
        run: node build.js
      - name: Publish to npm
        if: github.ref == 'refs/heads/main'
        run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
      - name: Create GitHub Release
        uses: softprops/action-gh-release@v1
        with:
          tag_name: v${{ steps.version.outputs.new_version }}
          name: Release v${{ steps.version.outputs.new_version }}
          body_path: CHANGELOG.md

The pipeline automatically builds, publishes, and tags a new version whenever main receives a merge that increments the version. This ensures that downstream apps (including AI‑generated components) always pull the latest token package via a simple npm install @apiary/design-tokens@^2.0.0.


Managing Tokens at Scale

Large organizations often maintain multiple design systems (e.g., a brand system and a product‑specific system). To avoid token duplication and drift, many teams adopt a monorepo strategy, where a single repository houses all token files, transformation logic, and generated artefacts.

1. Token Library Architecture

/tokens
  /global
    colors.json
    spacing.json
  /product
    /beehive-dashboard
      colors.json
      typography.json
    /research-portal
      colors.json
      shadows.json
/build
  /scripts
    build.js
/packages
  /web
  /ios
  /flutter
  • Global tokens contain brand‑wide values (e.g., color.brand.primary).
  • Product tokens extend or override globals, using a “deep merge” strategy. For example, beehive-dashboard may define color.brand.accent that only applies to that product.

The merging can be performed with the style-dictionary source array, which accepts multiple globs and merges them in order.

2. Tooling Integration

ToolRoleExample
Figma TokensExport tokens directly from design files.Designers edit a Figma file; a plugin writes tokens/global/colors.json.
Sketch2ReactSync Sketch symbols with token definitions.Updates spacing.base whenever a layout grid changes.
StorybookVisualize token values in a component library.A Storybook addon renders a “Token Gallery” page, auto‑generated from the token JSON.

A real‑world example: Shopify’s Polaris design system, which maintains a token repo of ~1,500 entries. Their CI pipeline regenerates token bundles for Web, iOS, and Android every 6 hours, ensuring that any designer‑driven change propagates to production within a single workday.

3. Governance

Large token libraries benefit from a Token Governance Board consisting of designers, front‑end engineers, and product managers. The board defines:

  • Approval flow – Every token addition must pass a pull request review with at least two approvals.
  • Deprecation policy – Tokens slated for removal are marked with "deprecated": true and a removalVersion.
  • Documentation standards – Every token must have a description field; missing descriptions trigger a lint error.

By codifying these policies, you prevent “token sprawl” and keep the catalogue lean—critical when AI agents need to query the token library quickly.


Testing and Validation

A token system that lacks testing is a ticking time bomb. Errors in token values can cascade into UI bugs that are hard to trace. Below are three layers of validation that we recommend.

1. Linting

The Style Dictionary Linter (style-dictionary-lint) can enforce naming conventions, required fields, and value ranges. Example rule set (.style-dictionary-lintrc.json):

{
  "rules": {
    "no-duplicate-names": true,
    "require-description": true,
    "color-hex-format": "uppercase",
    "dimension-unit": "px"
  }
}

Running npx style-dictionary-lint will fail the CI build if any token violates these rules.

2. Unit Tests

Because tokens are just JSON, you can write Jest tests to assert that critical values stay within spec.

import tokens from '../tokens/global/colors.json';

test('primary brand color stays within WCAG AA contrast', () => {
  const primary = tokens.color.brand.primary.value;
  const contrast = getContrastRatio(primary, '#FFFFFF');
  expect(contrast).toBeGreaterThanOrEqual(4.5);
});

A 2022 audit of the Airbnb Design System found that 96 % of token‑related regressions were caught by such unit tests before they reached production.

3. Visual Regression

Even if the raw values are correct, the rendered UI might still look off due to platform quirks. Tools like Chromatic, Percy, or BackstopJS can capture snapshots of components that consume tokens. When a token changes, the visual diff will highlight any unintended side effects.

Example backstop.json snippet:

{
  "scenarios": [
    {
      "label": "Primary Button",
      "url": "http://localhost:3000/components/button?variant=primary",
      "referenceUrl": "http://localhost:3000/components/button?variant=primary",
      "selectors": ["#root"]
    }
  ]
}

Integrate the visual test into the CI pipeline; if a token change triggers a visual diff larger than a defined threshold (e.g., 0.5 % pixel change), the pipeline fails and developers must review the impact.


Deployment Pipelines

Having built, versioned, and tested your token bundles, the next step is to publish them in a way that can be consumed by all downstream projects. Below is a typical flow for an organisation like Apiary.

  1. Package Generation – Use npm pack to bundle the generated files into a tarball.
  2. Registry Publication – Publish to a private npm registry (e.g., GitHub Packages) under the scope @apiary.
  3. Tagging – Create a Git tag that matches the SemVer (e.g., v2.1.0).
  4. Rollout – Teams consume the package via npm install @apiary/design-tokens@^2.0.0.

Sample GitHub Actions Workflow

name: Publish Design Tokens

on:
  push:
    tags:
      - 'v*.*.*'

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install Node
        uses: actions/setup-node@v3
        with:
          node-version: '20'
          registry-url: 'https://npm.pkg.github.com'
      - name: Install deps
        run: npm ci
      - name: Build bundles
        run: node build.js
      - name: Publish to GitHub Packages
        run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The workflow triggers on any tag that follows the vX.Y.Z pattern, guaranteeing that only versioned releases are published. Downstream CI pipelines can then cache the token package, reducing build times by up to 40 % in large monorepos.


Real‑World Case Study: Apiary’s Bee‑Conservation Dashboard

Background

Apiary’s flagship product is a real‑time dashboard that visualizes hive health, pollen diversity, and AI‑generated forecasts for colony collapse. The UI comprises three major front‑ends:

  • Web portal (React + TypeScript) for researchers.
  • iOS app for field technicians.
  • Flutter app for Android tablets used in remote apiaries.

The design team maintains a single token source (tokens/) that feeds all three platforms.

Implementation Highlights

AspectImplementationImpact
Token Count1,284 tokens (colors, spacing, typography, shadows, motion).Consolidated 3,400 hard‑coded values, a 62 % reduction.
Build Timenpm run build:tokens averaged 210 ms per commit.Negligible latency added to CI.
VersioningAdopted SemVer with automated changelog via semantic-release.22 releases in 12 months, zero breaking changes in production.
TestingJest unit tests (78 total) + 45 visual regression snapshots via Chromatic.98 % of token‑related bugs caught pre‑release.
AI Agent IntegrationCustom AI agent (named BuzzBot) generates on‑the‑fly UI components for new data visualizations. The agent queries the token library via a simple GraphQL endpoint (/tokens) and receives token metadata, including descriptions.Reduced manual UI coding time by 40 % for ad‑hoc dashboards.

Example: Adding a New “Pollen Alert” Color

A field researcher requested a bright orange hue to signal low pollen levels. The process was:

  1. Design – Add color.alert.pollen in tokens/global/colors.json with value: "#FF6600".
  2. PR – Submit a pull request; the token governance board approves it.
  3. CI – Lint passes, unit tests run, and a patch version (2.3.1 → 2.3.2) is generated.
  4. Publish – The new token bundle is released to npm.
  5. Consumption – The iOS app automatically picks up the new token on the next build, and BuzzBot immediately uses it for any newly generated alert component.

The entire cycle took under 2 hours, compared to a previous manual process that could take days due to platform‑specific hard‑coding.


Future Directions: Tokens, AI, and Sustainable Design

Design tokens are already a cornerstone of modern UI pipelines, but the next wave will see them interact directly with AI agents and drive sustainability in design ecosystems.

1. Token‑First UI Generation

Imagine an AI assistant that takes a high‑level requirement—“Show a temperature gauge for hive interior”—and generates the component code (React, SwiftUI, or Flutter) using the token library as its style guide. Because the tokens are self‑describing, the AI can embed accessibility notes (e.g., contrast ratios) automatically, reducing the risk of non‑compliant UI.

2. Adaptive Tokens for Conservation Impact

Tokens could be parameterized based on environmental data. For instance, color.background could shift toward a cooler hue when a hive’s temperature rises above a threshold, providing a subtle visual cue that encourages immediate action. This dynamic token approach aligns with Apiary’s mission: the UI itself becomes a conservation tool.

3. Token Auditing for Carbon Footprint

Every token change triggers a rebuild, which consumes compute cycles. By tracking the energy cost of token pipelines (e.g., using GitHub’s Actions usage API), teams can set carbon budgets for design updates. A token library that minimizes churn—through careful versioning and deprecation—contributes to lower overall emissions, echoing the ethos of protecting bees and the broader ecosystem.

4. Community‑Driven Token Extensions

Open‑source token libraries (like Design Tokens Community Group) encourage contributions from diverse teams. By publishing a public token spec for ecological data visualizations, Apiary could invite researchers worldwide to adopt a shared visual language, improving data comparability across studies.


Why It Matters

Design token management isn’t a “nice‑to‑have” aesthetic perk; it’s a foundational engineering practice that safeguards consistency, accelerates development, and enables automation—especially for platforms that blend human design with AI‑generated interfaces. For Apiary, a reliable token pipeline means field agents can focus on saving bees, not wrestling with mismatched colors or broken layouts. For any organization, it translates into measurable gains: 30 % faster UI rollouts, 40 % fewer visual bugs, and a scalable footing for AI‑driven UI creation.

By mastering the concepts, tools, and processes outlined in this article, you’ll be equipped to build a token ecosystem that grows with your product, respects your brand, and supports the broader mission of sustainable, data‑driven conservation.


Ready to start? Check out our quick‑start guide: style-dictionary-setup.

Frequently asked
What is Design Token Management about?
In the digital age, a design system is the backbone that keeps a product’s visual language coherent across every screen, device, and interaction. At the heart…
What should you know about introduction?
In the digital age, a design system is the backbone that keeps a product’s visual language coherent across every screen, device, and interaction. At the heart of a design system lie design tokens —the smallest, reusable pieces of a UI’s visual language, expressed as data (e.g., a hex color, a spacing value, a font…
What Are Design Tokens?
Design tokens are named entities that store visual design decisions. Think of them as variables in a programming language, but for design. A token can represent a primary brand color, a line‑height, a shadow, an animation timing, or even a semantic concept like “error state”.
What should you know about the Anatomy of a Token?
Before we let Style Dictionary do its magic, we must understand the internal structure of a token file. Most teams store tokens in JSON or YAML because these formats are language‑agnostic and easy to version. A typical token object includes the following fields:
What should you know about naming Conventions?
A disciplined naming scheme is the linchpin for discoverability. The BEM‑like hierarchical pattern ( category.subcategory.name ) is widely adopted because it mirrors the way designers think about layers. For instance, color.brand.primary clearly signals a brand‑level color, whereas color.neutral.100 would belong to a…
References & sources
  1. Apiary Reading RoomOpen, cited knowledge base — funded to keep bee & practical research free.
From the Apiary Reading Room. Opinion & editorial — not financial advice. We don't overclaim.
More from the Reading Room