Design tokens are the smallest pieces of a design system and they help to provide consistent visuals and experiences. Here’s how to use them strategically in your design system.
In the world of user interface (UI) development, consistency is king. Users often expect a product to feel cohesive and familiar, no matter which part they interact with. This is where design systems come in—collections of reusable components, guidelines and assets that help you provide a unified user experience across an entire product or product suite.
Design tokens are fundamental building blocks to design systems that offer a unified and consistent user experience across different parts of a product. In this article, we’ll delve into what design tokens are, why they are crucial and how they can be effectively implemented to uphold consistency throughout a product.
Design tokens are essentially the smallest parts of a design system. They are named entities that store specific visual design attributes (like colors, typography, spacing and more) within a design system. These tokens act as a bridge between design and development, providing a single source of truth for these attributes. This means that instead of hard-coding values directly into our code, we reference design tokens, which can be updated centrally.
For example, a design system might define a set of color tokens:
// Colors
$kendo-color-primary: #ff6358;
$kendo-color-secondary: #666666;
$kendo-color-tertiary: #03a9f4;
$kendo-color-info: #0058e9;
$kendo-color-success: #37b400;
$kendo-color-warning: #ffc000;
In addition to colors, design tokens can also define other aspects of design, such as font sizes, font families, line heights, spacing and more.
// Font sizes
$kendo-font-size: 0.875rem;
$kendo-font-size-xxs: 0.5rem;
$kendo-font-size-xs: 0.625rem;
$kendo-font-size-sm: 0.75rem;
$kendo-font-size-md: $kendo-font-size;
$kendo-font-size-lg: 1rem;
$kendo-font-size-xl: 1.25rem;
In the above examples, we’re defining our design tokens as Sass variables assuming the Sass preprocessor is being used in the project. We could also use CSS custom properties, which offer similar benefits for maintainability and scalability within modern web projects.
/* CSS Variables */
:root {
--kendo-color-primary: #ff6358;
--kendo-color-secondary: #666666;
--kendo-color-tertiary: #03a9f4;
--kendo-color-info: #0058e9;
--kendo-color-success: #37b400;
--kendo-color-warning: #ffc000;
--kendo-font-size: 0.875rem;
--kendo-font-size-xxs: 0.5rem;
--kendo-font-size-xs: 0.625rem;
--kendo-font-size-sm: 0.75rem;
--kendo-font-size-md: 0.875rem;
--kendo-font-size-lg: 1rem;
--kendo-font-size-xl: 1.25rem;
}
When it comes to using these tokens in a project, developers have different methods for referencing them in their code. One of the most common ways to access these design tokens in CSS is by using the var() function to retrieve custom properties. This method is especially beneficial for maintaining a consistent design across a large-scale application and makes it easier to make global changes.
For instance, in a CSS file, we can apply design tokens to elements like this:
.button {
background-color: var(--kendo-color-primary);
padding: var(--kendo-font-size-sm) var(--kendo-font-size-md);
font-size: var(--kendo-font-size);
}
.header {
color: var(--kendo-color-info);
font-size: var(--kendo-font-size-lg);
}
Here, the var()
function is used to insert the value of a custom properties where they’re referenced. This allows us to easily switch themes or adjust styles by simply changing the values of these tokens at the root level.
Design tokens can be expansive, encompassing a variety of types that cater to different aspects of a design system. The Progress Design System showcases a helpful structure of design tokens ranging from global values to very specific ones tailored for particular components.
Global design tokens are foundational values that form the cornerstone of a design system. They represent tokens that are:
For instance, a color palette might include tokens like $purple-100
, $purple-200
, $purple-300
, etc., establishing a scalable and reusable color system. Though these tokens can be used directly, they’re often used as building blocks and are referenced by other design tokens.
Alias design tokens are a step more specific than global tokens. They are named in a way that suggests their intended use, helping to apply consistent styling across different UI elements while maintaining clear and meaningful connections to their function within the design system.
For example, $kendo-color-info
might be specifically used for informational messages or alerts, signaling its purpose through its name.
Component-specific design tokens take specificity even further. These tokens are directly tied to particular components within the design system, defining properties such as colors, borders and typography specific to that component.
For instance, the $kendo-button-border
might define the border style for all buttons within a system. This level of detail helps each component to behave and appear as expected, no matter where it is used within the application.
Application-specific design tokens are crafted to address the particular needs of individual projects or a series of related projects. They provide the flexibility needed to adapt the overarching design system to specific functional requirements, aesthetic preferences or brand guidelines. They often encompass several types of properties:
Implementing design tokens in certain ways can be helpful for maximizing their benefits and ensuring the consistency and scalability of a design system. Drawing from the guidelines provided by the Progress Design System, here are some practical do’s and don’ts to follow when working with design tokens.
Global design tokens serve as the foundation of a design language. They are versatile and can be applied across different parts of your project without being tied to specific UI components.
Do:
Don’t:
Component-specific design tokens are tailored for specific elements within the UI, such as buttons, input fields or navigation bars. They help give components a consistent appearance and behavior across different parts of your application.
Do:
Don’t:
Application-specific design tokens are designed to meet the unique stylistic requirements of a particular project or suite of projects. These tokens allow for the customization of designs to align with specific branding guidelines and functional requirements.
Do:
Don’t:
In conclusion, design tokens are not just tools for maintaining visual consistency—they are strategic assets in a design system that enhance collaboration across teams, align detailed design elements with broader brand narratives and adapt gracefully to the ever-changing requirements of modern digital projects. As such, proper implementation and management of design tokens are essential for any organization that values design quality and coherence across its product suite.
For more details, explore the helpful guidelines provided by the Progress Design System and their documentation on Design Tokens.
Hassan is a senior frontend engineer and has helped build large production applications at-scale at organizations like Doordash, Instacart and Shopify. Hassan is also a published author and course instructor where he’s helped thousands of students learn in-depth frontend engineering skills like React, Vue, TypeScript, and GraphQL.