wpTruss

How Design Tokens Work in CSS

3 min read

If you’ve spent more than five minutes in the WordPress ecosystem lately, you’ve probably heard the term Design Tokens. It sounds like high-level enterprise architect talk, but for those of us building client sites every day, it is actually the “missing link” that stops our CSS from becoming a mess.

In this guide, we’re going to strip away the jargon and look at how design tokens work in plain CSS, and why they are the secret to building maintenance-free WordPress sites.


The Problem: The “Snowflake” Hex Code

Imagine a client asks you to change their brand orange. In a traditional WordPress setup, that orange hex code (#FF6B35) is hidden in:

  1. Your theme’s style.css.
  2. The “Customizer” settings.
  3. Serialized data inside 40 different Gutenberg blocks.
  4. Elementor or Bricks global styles.

When you change it in one place, you miss it in three others. Your site becomes a “snowflake”—every page is slightly unique, and not in a good way.

What is a Design Token?

At its simplest, a Design Token is a name that represents a value.

Instead of remembering #FF6B35, you use a name like brand-primary.

In the world of CSS, these tokens are powered by CSS Custom Properties (often called CSS Variables).

The Traditional Way (Hardcoded)

.button {
    background-color: #FF6B35; /* If this changes, you have to find every instance */
}

The Token Way (Dynamic)

:root {
    --tp-color-brand-primary: #FF6B35;
}

.button {
    background-color: var(--tp-color-brand-primary); /* If the token changes, the button updates automatically */
}

The 3 Layers of a Design Token

To make this work at scale (like we do in wpTruss with our 141 design decisions), tokens usually follow a three-layer logic:

  • The Value (The Raw Material): The actual hex code, pixel value, or font name. (e.g., #000000).
  • The Primitive (The Name): A simple name for the value. (e.g., --tp-color-black).
  • The Semantic Token (The Purpose): A name based on how it is used. (e.g., --tp-color-text-body).

Why does this matter? Because one day you might want your “body text” to be dark blue instead of black. If you used the name black, your code would say color: var(--black) but look blue. If you use text-body, your code still makes sense.

Why This is a Game Changer for WordPress

Most WordPress themes “own” your design. If you switch from Astra to GeneratePress, your design settings often vanish or break.

By using a Token-First approach (like the wpTruss engine), you move the design decisions out of the theme and into a “Governance Layer.”

1. Zero CSS Fights

Since every block uses the same tokens (like --tp-spacing-md or --tp-radius-lg), your spacing and corners always match. You don’t have to “fight” the theme’s CSS because the tokens dictate the layout.

2. Instant Rebranding

In wpTruss, changing a brand color in the admin panel updates the CSS variables in the :root. Because every block is wired to those variables, the entire site transforms instantly—without you opening a single stylesheet.

3. AI-Ready Code

Modern AI agents like Claude or Cursor struggle with messy, hardcoded CSS. But if you tell an AI, “Build me a card using --tp-color-surface and --tp-spacing-lg,” it can generate perfect, brand-compliant code every time.

How to Start Using Tokens Today

You don’t have to rewrite your whole workflow at once. Start with these three steps:

  1. Stop using Hex Codes: Define your 5 core colors as CSS variables at the top of your stylesheet.
  2. Standardize Spacing: Pick 4 sizes (Small, Medium, Large, XL) and map them to variables like --gap-md.
  3. Use Semantic Names: Don’t name a variable --blue-button. Name it --action-primary.

The bottom line:

Design tokens take the “guesswork” out of development. They turn a messy collection of styles into a system.

Want to see what 141 design tokens look like in a real WordPress environment? Check out the wpTruss Design Token Reference.