Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

React
  • One Request, Two Answers: the Same Post as an HTML Page and as JSON
  • A Blog Design from a Prompt: Downloading Figma Make Code and Reading App.tsx and BlogCard.tsx
  • How a Web Page Works: HTML Tags, Elements and Attributes
  • Semantic HTML: header, nav, main, aside and footer as Page Landmarks
  • HTML Forms: Labels, Names, Input Types and Where the Data Goes (GET vs POST)
  • CSS Basics: Selectors, Which Rule Wins, and the Box Model
  • CSS Flexbox vs Grid: A Nav Bar, a Card Row and a Dashboard
  • Responsive CSS: Viewport, Mobile-First Media Queries, clamp() and Dark Mode with Tokens
  • JavaScript for People Who Already Code: Syntax, Modules and Five Surprises
  • JavaScript Arrays the Functional Way: map, filter, reduce, find, sort and Object.entries
  • Async JavaScript: Promises, async/await, fetch and Promise.all
  • JavaScript in the Page: the DOM, querySelector and Events
  • npm, package.json and Vite: What npm install Fetches and How Vite Serves and Builds Your Page
  • TypeScript Essentials: Types Checked, Then Erased (Interfaces, Unions, Generics)
  • Why React, JSX and Components: The Page as a Function of Data
  • React Props and Composition: Data Down, Calls Up, Children in the Slot
  • Routing With React Router: One Page, Many Addresses
  • React Component Tests With Vitest and Testing Library: Test What the User Sees
  • End-to-End Tests for a React App With Playwright: A Full Dress Rehearsal
  • Why AI-Built Websites All Look the Same, and Four Levels That Fix It
  • Visual Hierarchy, Spacing and the 8-Point Grid: Tell the Eye What to Read First
  • Colour, Contrast and Dark Palettes: 60-30-10, Semantic Tokens and Ratios You Can Compute
  • Typography That Sells: Type Scale, Line Length and Free Font Pairings
  • The UI Element Catalogue: Buttons to Toasts, Their Jobs, States and shadcn/ui Names
  • Design Tokens: Primitive and Semantic Tokens, from Figma to CSS to Tailwind
  • Tailwind CSS 4 in React: Utility Classes, Responsive Prefixes, Hover and Dark Mode
  • shadcn/ui in React: Components You Own, Edit and Commit
  • Design Tokens to a Tailwind Theme: Light and Dark Mode with @theme inline
  • Motion in React: Entrance, Hover, Exit and Layout Animations
  • A React Dashboard: Stat Cards, a Recharts Line Chart and a Sortable Table
  • Accessibility in Practice: Dialogs, Menus and the Keyboard in React
  • Reference-Driven Design: Extract a DESIGN.md From a Site You Admire and Build From It
  • Components, Variants and Variables: One Design System in Figma and in CSS
  • Figma MCP Server: Build a React Component From a Frame, Then Write It Back
  • Claude Design: From a Brief to a Clickable Prototype, Then Hand It Off to Claude Code
  • Critiquing AI-Generated UI: Six Checks for Every Screen
  • The AI Design Landscape: Prompt to UI, Prompt to App, and Design to Code
  • Your Brand Rules Folder: One Folder Every AI-Built Page Follows
  • The Best-Practice UI Prompt: Plain Sentences That Beat the Average AI Page
  • UI Ideas From Figma Make, Google Stitch and ChatGPT: One Prompt, Three Designs
  • Google Stitch From a Sketch or Screenshot: Show the Layout, Say What to Keep
  • Stitch to Figma to Code: Turn a Stitch Screen Into Code That Uses Your Tokens
  • Figma Make: Prompt to Prototype With a Four-Part Prompt
  • Upgrade a Dated UI From One Screenshot (or a Reference Image)
  • States and Feedback: Make Every Click Get an Answer
  • A Design-Loop Skill: Claude Screenshots, Scores and Fixes Its Own UI
  • Copy Without the AI Tells: A Copy Pass on a Landing Page
  • React State, Events, Lists and Conditional Rendering: Follow One Click
  • React useEffect: When It Runs, What Cleanup Is For, and When You Don't Need One
  • Lifting State Up, Refs and React DevTools: Put State Where It Is Needed
  • Forms and Actions in React 19: Controlled Inputs, Form Actions, useActionState and useFormStatus
  • React Context and Custom Hooks: Share One Value, Reuse the Logic
  • Server State With TanStack Query: One Key, One Request, One Cache
  • Mutations and Optimistic Updates in TanStack Query: Change Data, Then Tell the Cache
  • Generate TypeScript Types, Query Hooks and Zod From an OpenAPI Spec With Orval
  • A Mock Backend in the Browser With Mock Service Worker, Generated From the Spec
  • A React Client for a FastAPI API: The CORS Wall, CORSMiddleware and the Vite Proxy
  • Forms With React Hook Form and Zod: The API's Rules in the Browser, the Server's Errors Under the Field
  • JWT Auth in a React Client With a FastAPI Backend: Log In, Carry the Token, Let the Server Decide
  1. Blog
  2. /
  3. React
  4. /
  5. Fundamentals

Design Tokens: Primitive and Semantic Tokens, from Figma to CSS to Tailwind

A design token is a name for a value, like colour 47 on a paint chart. Build primitive and semantic tokens in tokens.css, reuse the same names in a Tailwind CSS 4 @theme block, and re-skin a card by changing one line.

Chaand Sheikh

·27 November 2026·Updated 28 November 2026Fundamentals

What you will learn

  • Explain a design token as a name for a value
  • Split tokens into primitive tokens and semantic tokens
  • Use the same token names in plain CSS variables and a Tailwind CSS 4 @theme block
  • Re-skin a component by changing one token line

Before you start

  • Basic HTML and CSS
  • Colour, Contrast and Dark Palettes

Imagine you are painting four rooms, and you tell every painter "use that nice blue". Four painters, four slightly different blues. Nobody notices until it is everywhere.

That is exactly what happens in an app when every file types its own colour code. Now take a paint chart where every colour has a number. You say "colour 47", and everyone paints the same colour. Change the chart once, and every room follows.

A design token is colour 47 on that chart: a name for a value. The whole team uses the name, not the value. In this article you will see tokens in plain CSS first, then the same names in Tailwind CSS 4.

Primitive tokens and semantic tokens

Tokens come in two layers.

Primitive tokens and semantic tokens Primitive: which colours exist --indigo-600 --emerald-600 --slate-900 --white --slate-100 Semantic: named by the job --color-brand --color-ink --color-surface --color-page Screens useonly these
Semantic tokens point at primitives. Screens only ever use the semantic names.
  • Primitive tokens are the chips on the chart: indigo 600, emerald 600, slate 900, slate 100, white. They say which colours exist. They do not say where to use them.
  • Semantic tokens are named by the job: --color-brand for buttons and links, --color-ink for text, --color-surface for cards, --color-page for the page background. Each one simply points at a chip.

The rule: screens use only the semantic names, and the primitives stay behind the scenes. Tomorrow the brand can move to another chip and no screen needs to know.

The real tokens file

Here is tokens.css from the project, every line of it:

:root {
  /* primitives: the paint chart */
  --indigo-600: #4f46e5;
  --emerald-600: #059669;
  --slate-900: #0f172a;
  --slate-100: #f1f5f9;
  --white: #ffffff;
  /* semantic: what each colour is for */
  --color-brand: var(--indigo-600);
  --color-ink: var(--slate-900);
  --color-surface: var(--white);
  --color-page: var(--slate-100);
  --spacing-card: 24px;
  --radius-card: 14px;
  --font-body: "Inter", system-ui, sans-serif;
}

It starts with :root, so these variables are available everywhere. First the primitives: five chips with raw values. Then the semantic layer, where --color-brand is var(--indigo-600) and so on. And it is not only colour. --spacing-card is 24px, --radius-card is 14px, and --font-body is Inter with a system font as backup.

The card uses the names

Now card.css uses them:

.card {
  background: var(--color-surface);
  padding: var(--spacing-card);
  border-radius: var(--radius-card);
  border-top: 8px solid var(--color-brand);
}
.card h2 { margin: 0 0 6px; font-size: 26px; }
.card p { margin: 0 0 14px; font-size: 18px; }
.bar { height: 12px; border-radius: 99px; background: var(--color-page); margin-bottom: 18px; }
.bar i { display: block; width: 65%; height: 100%; border-radius: 99px; background: var(--color-brand); }
.card button {
  background: var(--color-brand);
  color: var(--color-surface);
  border: 0;
  padding: 12px 22px;
  border-radius: var(--radius-card);
  font: 700 18px var(--font-body);

The card background is var(--color-surface). The padding, the radius and the top border all come from tokens. The button background is the brand colour, and its text is the surface colour. It draws a task card: "Write report", assigned to Emma, due Friday, with a progress bar and a Mark done button.

Notice there is no colour code in this file. Only token names. That is the whole point.

The same tokens as a Tailwind @theme

Now the same tokens in Tailwind CSS 4. This is theme.css:

@import "tailwindcss";

@theme {
  --color-brand: #4f46e5;
  --color-ink: #0f172a;
  --color-surface: #ffffff;
  --color-page: #f1f5f9;
  --spacing-card: 24px;
  --radius-card: 14px;
  --font-body: "Inter", system-ui, sans-serif;
}

The first line imports Tailwind, then comes an @theme block with the same names. Plain values this time. Tailwind reads that block and creates the classes for you: bg-brand, text-ink, bg-surface, p-card, rounded-card and font-body. The page from ex02-tailwind-theme/index.html uses them like any other class:

<body class="bg-page text-ink font-body p-7">
  <div class="bg-surface p-card rounded-card border-t-8 border-brand">
    <h2 class="text-2xl font-bold">Write report</h2>
    <p class="mb-4">Assigned to Emma, due Friday</p>
    <button class="bg-brand text-white font-bold px-5 py-3 rounded-card">Mark done</button>
  </div>

Same names, same values, and Tailwind writes the classes. You do not have to memorise any of this, because AI can write these blocks for you. You only need the foundation, so the code makes sense when your app grows.

Change one line, re-skin the app

The card uses --color-brand, which points at indigo 600. Now change one line in tokens.css:

/* before */
--color-brand: var(--indigo-600);
/* after */
--color-brand: var(--emerald-600);

Nothing else. The top border, the progress bar and the button all turn green. We did not touch card.css. One line changed and everything followed. Now imagine doing that on a hundred screens without tokens.

From Figma to the screen, one source

Where do the tokens come from? In most teams a designer defines them in Figma as variables, and the same name then travels all the way to the screen.

From Figma variables to CSS to Tailwind to the screen 1. Figmabrand =Indigo 600 2. tokens.cssCSS variable--color-brand 3. @themeTailwind classbg-brand 4. Screensuse thename Change the token once at the start, and every step after it updates.
One name travels from the design file to the class on the screen.

Step one, in Figma: brand equals Indigo 600. Step two, it is exported as a CSS variable in tokens.css. Step three, the same name becomes a Tailwind class through the theme block. Step four, every screen uses the name. Change the token once at the start and every step after it updates. That is what "one source of truth" means.

The next step is to give the same names two sets of values, one for light mode and one for dark. That is in design tokens to a Tailwind theme with dark mode.

Common mistakes

  • Using primitives in components. background: var(--indigo-600) in a card works today, but when the brand moves to emerald, that card stays indigo. Use --color-brand.
  • Naming semantic tokens by colour. --color-blue is a primitive in disguise. Name it by the job.
  • Two sets of names. If Figma says brand and the CSS says primary-blue, the chain breaks and someone copies values by eye. Keep one name all the way.

Recap

IdeaIn one line
Design tokenA name for a value
Primitive tokenA raw chip: --indigo-600: #4f46e5
Semantic tokenNamed by the job: --color-brand: var(--indigo-600)
Tailwind 4 @themeThe same names become classes like bg-brand
One source of truthChange a value once, the whole app follows

The same token idea in Figma, with variables, modes and component variants, is in components, variants and variables.

Try it yourself: open the project, point --color-brand at another chip, and watch the card change. Then copy the same names into a Tailwind theme.

Keep going in React · 25 of 59

Previous
The UI Element Catalogue: Buttons to Toasts, Their Jobs, States and shadcn/ui Names
Next post
Tailwind CSS 4 in React: Utility Classes, Responsive Prefixes, Hover and Dark Mode
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Related posts

One Request, Two Answers: the Same Post as an HTML Page and as JSON

Ask a Django blog for the same post twice: once as a 12,731-byte HTML page built by a template, once as 2,976 bytes of JSON built by a serializer. Compare the headers, see who builds the page, and why the server still owns every write.

A Blog Design from a Prompt: Downloading Figma Make Code and Reading App.tsx and BlogCard.tsx

Make a blog design from a prompt in Figma Make, download src.zip, unzip it with Python's zipfile module, and read the two files that matter: App.tsx with its selectedPost state and BlogCard.tsx with its props.

How a Web Page Works: HTML Tags, Elements and Attributes

A web page is a text file full of labelled pieces. Learn tags, attributes and nesting with three tiny pages, and see what breaks when an attribute or a closing tag is wrong.

Semantic HTML: header, nav, main, aside and footer as Page Landmarks

The same page written as div soup and with semantic tags looks identical, but only one gives screen readers and search engines landmarks and an outline. Plus tables, div, span and the one-main rule.

On this page

  • Primitive tokens and semantic tokens
  • The real tokens file
  • The card uses the names
  • The same tokens as a Tailwind @theme
  • Change one line, re-skin the app
  • From Figma to the screen, one source
  • Common mistakes
  • Recap
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.