Design tokens and why design systems need them?

Responses (0)


Newline logo

Hey there! đź‘‹ Want to get 5 free lessons for our The newline Guide to React Component Design Systems with Figmagic course?

Clap
1|0|

One magic, simple concept (design tokens) and a one-stop shop (Figmagic) to contain our design make one hell of a powerhouse.

Let's learn what design tokens are and how you can work with a “structured design” approach using Figmagic, a command-line interface tool that extends what we can do with Figma. Figmagic lets us do three things: pull design tokens, extract graphics, and generate React components.

In this post, we will discuss the core concept "design tokens".

Structured design and controlled evolution#

Tokens offer a form of “contract” between a designer’s intent and its fulfillment by developers. This means that both sides agree to treat the individual parts of a complete design through the tokens that represent those values. As a format, they are super easy to read, understand, and adapt for consumption by many types of systems or applications. That’s very important as you start doing cross-platform apps and anything similarly complex.

Tokens ensure that values are not magic numbers or ”just picked at random.” This makes communication precise and effortless. Creating actual code for components, even complex ones also becomes a lot less of a bore since what you are doing is just pointing stuff like padding, Z indices, and anything else to their token representations.

For instance, we need to add margins to a box. Let's see what we have available:

Given the above, the small spacing is the single spacing you can use for your margins, paddings, or other sizes. For sure, you sometimes need to hardcode new unique values, but that should happen in a very small number of instances. I call this approach "structured design"—no need to make it a big concept—but it's an approach in which we leave as little as possible to chance. As far as possible, we use the tokens instead of hard-coding any values.

With a single spacing it does, however, seem reasonable to believe that it's time to add some more to cater to more dynamic, realistic needs, so let's evolve the model a tiny bit:

We now have two possibilities, and both are perfectly valid choices. The evolution process should be done in collaboration between the designers and developers.

Token consumers#

So, where do these tokens come from?

The token has to be communicated and stored somewhere and then exported to a useful format—like our example JSON file. The exported token files themselves do not, therefore, usually constitute "the truth" as such but act only as a kind of transport artifact for the truth: Figma. The implication of this is that they only fill the role of moving a value from one system (Figma) to a variety of others (anything that accepts JSON, for example).

The designer, in turn, needs to ensure correspondence between Figma styles and design tokens on their end.

The rest of the tooling just happens to be things I feel are very good and happen to work well together.

It's really smart to work in a structured way by assembling design systems from design tokens. Using tokens, we can shape simple elements, which can then be ordered into components and then into compositions and views from those.

Design tokens fairly directly tend to create a form of taxonomy of what things exist and in which relations. So, your color "green" will be a very flat and direct way of saying what they are, but it won't say anything about where they are used. That information can be handled in other ways—though you can also use aliases to set a value like "orange" to an auxiliary value like "color-accent," thus naming by purpose:

What makes sense for you to use is often use case-dependent.

Magic updates#

This can also, given the right tooling, provide the side effect of making updates to token values magically update the actual code. Bigger updates, like changing from a token X to token Y, will still require a code change, but the effort is practically negligible. By their nature, design tokens enforce the standards you have set up.

How we use the tokens#

Some advice for the road, as you start using design tokens in actual projects:

  • Use design tokens as a shared language

  • Evolve your token list over time and usage—add and remove as needed

  • Stay creative with tokens; think of them as lego bricks and not as laws

  • Do token management completely in Figma

  • Connect your token values to Figma Styles as soon as possible, so you get a two-way effect

Using design tokens as a part of your workflow will most likely make it easier to communicate the design, faster to work with coding a design, and less susceptible to breaking between UI expectations and how the design is actually coded.

Coming Soon!##

We're working on a new course, The newline Guide to React Component Design Systems with Figmagic, where we go deep into a design-driven workflow giving you all the pieces—from code to know-how—to implement a design system and make it operational for web-based development.

If you're looking to improve your whole team's way of working with releasing and designing continuously with a shared basis in a design system, The newline Guide to React Component Design Systems with Figmagic is the course that puts together the entire picture, from theory, to process, to practical setup.


Clap
1|0