Introduction to Design Tokens
Tags: javascript, webdev, systems, css
Published: 2021-09-12 02:08:33

The following is an excerpt from my book, [Design Systems for Developers](https://leanpub.com/designsystemsfordevelopers), where I teach you how to ship a design system driven by design tokens based on first-hand experience.

## High Fidelity
Every design system has the "high fidelity" design specifications encapsulated in a design file, and usually some form of documentation.

> These design files are called "high fidelity" because they are the purest, or most faithful, expression of the design system.

![design-tokens](https://polaris.shopify.com/bundles/81f2bcee4972a4a6f281ad417ebe51e5.png)

In other words, if you see a design specification in the design file, it is highly likely that it is what the designers want a consuming application to emulate.

If the design file says to use `#ff000` as the color for _error_ text, then, as a developer, you trust that is what your application should follow.

The only way that the specification is "unpure," or inaccurate of the designers' intent, is if someone made a mistake when creating the design file and didn't realize it.

Regardless if there are actually any mistakes, developers always go off of what the latest version of a design file (or some documentation) specifies.

## Translating Design Specifications into Code
Whether it's in CSS variables, SASS variables, JavaScript objects, or something else, all the assets/tools of a design system have to translate the official design specifications from a design file.

> The high fidelity design specifications in the design file have to be encapsulated, or represented, in some code.

The goal is to have design specifications represented in code to be high fidelity as well, in that it follows the design file with 100% accuracy.

The point of this all is to say that the design specifications have to be represented in code and that representation is important.

So important that it deserves a name.

## Design Tokens

> _Design tokens_ are simply a name, or label, for the design specifications you represent in code.

![design-tokens](https://images.unsplash.com/photo-1579758258316-57081bac8ea8?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1268&q=80)

Now, a design file has different types of design specifications.

### Simple Tokens
There are design specifications that are _simple values_.

They are simply enumerations of valid _values_ that may be used in accordance with the design system.

For example, design systems usually specify a color palette. A color palette is an enumeration of the official/valid colors of the design system.

It doesn't specify when and where the colors should be used, only that they are the official colors.

Therefore, the design tokens that represent the "simple" design specifications, like the official colors, typography, etc., are called _simple tokens_.

### Component Tokens
Other design specifications specify the styles for UI  _components_.

The specifications for UI components do not merely enumerate a set of valid values. They specify how a valid value should be applied to a UI component.

In other words, a UI component is created by composing a set of simple values.

Therefore, the design tokens that represent the specifications of a UI component may be called _component tokens_ or _composed tokens_.

The former label captures the literal meaning and the latter label captures the technical meaning.

## Conclusion
By using the terminology _design tokens_, we have a way to speak of our design specifications represented in code in a platform and technology-agnostic manner.

![design-tokens](https://spectrum.adobe.com/static/images/design_tokens@2x_5c8glXNcJexroU3y3AEUA3_1611634793000.png)

We'll learn in the next chapter that this not only is helpful for communication as it also has technical significance.

<hr />

## Want to learn everything else you need to ship a design system into production based on design tokens? Check my ebook 👇

[![ebook](https://pbs.twimg.com/profile_banners/4780614459/1620839152/1500x500)](https://leanpub.com/designsystemsfordevelopers)