# Token Aliasing and Inheritance Strategy

> Learn to implement a design token aliasing and inheritance strategy to create highly flexible, maintainable systems prepared for multiple themes.

*Tags: ux, technique, ui-design, product-design, development*

---


> [!info] Quick Definition
> Token **Aliasing** consists of defining a token that refers to another token instead of a raw value (like a hexadecimal or pixels). **Inheritance** is the logical structure that allows design decisions to flow from the most general to the most specific, ensuring consistency and total flexibility in the system.


## What is Token Aliasing?

Imagine you want to buy a car in "Sporty Color".
1.  **Raw Value:** `Red #FF0000`
2.  **Primitive Token (Global):** `brand-red` -> `#FF0000`
3.  **Semantic Token (Alias):** `color-background-cta` -> `brand-red`

In this example, `color-background-cta` is an alias of `brand-red`. If tomorrow you decide that your brand's sporty color is Orange, you only have to change the alias reference to `brand-orange`, and automatically all the call-to-action (CTA) buttons in your product will update. Without aliasing, you would have had to manually search for setiap instance of the color red and change it.

## The Ladder of Abstraction: Inheritance Layers

A robust inheritance strategy is typically based on three levels, where each level "inherits" from the previous one:

### Level 1: Primitive Tokens (Core)
They are the base of the pyramid. They contain literal values (hexadecimal, rem, ms).
- **Name:** Descriptive of the value (e.g., `grey-100`, `blue-500`, `space-16`).
- **Use:** 99% of the time they **should not be used directly** in components. Their function is to feed the next layer.

### Level 2: Semantic Tokens (Theme)
This layer adds **meaning and purpose**. This is where the true power of design systems resides.
- **Name:** Descriptive of its function (e.g., `bg-surface-primary`, `text-color-error`, `action-bg-hover`).
- **Use:** These are the tokens that designers and developers should use 90% of the time. They allow switching themes (Light/Dark Mode) with a single click.

### Level 3: Component Tokens (Specific)
It is the most granular level, reserved for very specific adjustments that should not affect the rest of the system.
- **Name:** Based on the component (e.g., `button-primary-bg`, `tab-active-indicator-color`).
- **Use:** They are used for edge cases where a component needs a value that does not fit any general semantic token.

## Advantages for the Product Lifecycle

- **Simplified Maintenance:** Changing the visual identity of a complex product takes minutes or seconds, not weeks of code and design refactoring.
- **Theming Support:** Greatly facilitates the creation of Dark Mode, High Contrast Modes, or White Label versions of the same application.
- **Guaranteed Consistency:** By centralizing decisions in aliases, you prevent different parts of the app from using slightly different "shades of red" by mistake.
- **Scalability:** Adding new platforms or products to the brand is much easier if you already have a logical token structure.

## Conflicts and Common Errors

- **Too Many Aliases:** Creating an alias for every pixel of the interface can make the system unmanageable. Look for the balance between flexibility and simplicity.
- **Circular Aliasing:** Avoid `token A` pointing to `token B`, which in turn points back to `token A`. This will break any token transformation engine.
- **Non-Agnostic Names:** Do not name your semantic aliases after their current color (e.g., `color-action-red`). If you change the color, the name will be confusing. Use names based on function (e.g., `color-action-danger`).

## Mentor's Tips

- **Draw your scheme first:** Before you start creating tokens in Figma or in code, draw on a piece of paper or whiteboard how your alias layers are going to relate.
- **Document the intent:** In your design system manual, explain why one token points to another. "Why does the modal background use `bg-surface-secondary` and not `bg-surface-primary`?".
- **Use inspection tools:** Plugins like *Token Studio* in Figma allow you to visually see the inheritance of each token, which greatly facilitates debugging the system.

## Useful Resources and Tools

- **Style Dictionary (Amazon):** The key tool for managing token inheritance and exporting them to multiple platforms.
- **Token Studio Plugin for Figma:** Allows creating and managing aliases natively on your design canvas.
- **W3C Design Tokens Community Group:** To understand where the official design token and aliasing standard is headed.
- **Books:** *Design Systems* by Alla Kholmatova (excellent for understanding the semantics of visual language).
---


---

Source: https://www.fernandoux.com/en/wiki/techniques/token-aliasing-inheritance/
