Repository navigation
Tailwind Output
tailwind.css is for Tailwind CSS v4 (tested against 4.3.3). Turn it off with tailwind: false and use tokens.css alone.
It is built from the same tokens as tokens.css and has up to three sections. This is the complete file the example writes:
/** AUTO-GENERATED by figma-tokens — do not edit. */
/* 1 ─ raw tokens → utilities (primitives: white/black) */
@theme inline {
--color-primitive-white: var(--color-primitive-white);
--color-primitive-black: var(--color-primitive-black);
--color-semantic-light-brand-primary-10: var(--color-semantic-light-brand-primary-10);
--color-semantic-light-brand-primary: var(--color-semantic-light-brand-primary);
--color-semantic-light-brand-on-primary: var(--color-semantic-light-brand-on-primary);
--color-semantic-light-neutral-background: var(--color-semantic-light-neutral-background);
--color-semantic-light-neutral-on-background: var(--color-semantic-light-neutral-on-background);
--color-semantic-light-status-error: var(--color-semantic-light-status-error);
--color-semantic-dark-brand-primary: var(--color-semantic-dark-brand-primary);
--color-semantic-dark-brand-on-primary: var(--color-semantic-dark-brand-on-primary);
--color-semantic-dark-neutral-background: var(--color-semantic-dark-neutral-background);
--color-semantic-dark-neutral-on-background: var(--color-semantic-dark-neutral-on-background);
--radius-sm: var(--radius-sm);
--radius-md: var(--radius-md);
--duration-primary: var(--duration-primary);
--font-fa-primary: var(--font-fa-primary);
--size-body: var(--size-body);
--size-heading-lg: var(--size-heading-lg);
--font-weight-regular: var(--font-weight-regular);
--font-weight-bold: var(--font-weight-bold);
}
/* 2 ─ semantic layer: light by default, flips under .dark */
:root {
--color-brand-primary-10: var(--color-semantic-light-brand-primary-10);
--color-brand-primary: var(--color-semantic-light-brand-primary);
--color-brand-on-primary: var(--color-semantic-light-brand-on-primary);
--color-neutral-background: var(--color-semantic-light-neutral-background);
--color-neutral-on-background: var(--color-semantic-light-neutral-on-background);
--color-status-error: var(--color-semantic-light-status-error);
--font-sans: var(--font-fa-primary);
}
.dark {
/* --color-brand-primary-10: no dark token in Figma — keeps light value */
--color-brand-primary: var(--color-semantic-dark-brand-primary);
--color-brand-on-primary: var(--color-semantic-dark-brand-on-primary);
--color-neutral-background: var(--color-semantic-dark-neutral-background);
--color-neutral-on-background: var(--color-semantic-dark-neutral-on-background);
/* --color-status-error: no dark token in Figma — keeps light value */
}
/* 3 ─ semantic names → utilities */
@theme inline {
--color-brand-primary-10: var(--color-brand-primary-10);
--color-brand-primary: var(--color-brand-primary);
--color-brand-on-primary: var(--color-brand-on-primary);
--color-neutral-background: var(--color-neutral-background);
--color-neutral-on-background: var(--color-neutral-on-background);
--color-status-error: var(--color-status-error);
--color-primary: var(--color-brand-primary);
--color-primary-foreground: var(--color-brand-on-primary);
--color-background: var(--color-neutral-background);
--color-foreground: var(--color-neutral-on-background);
--color-destructive: var(--color-status-error);
--text-body: var(--size-body);
--text-heading-lg: var(--size-heading-lg);
--transition-duration-primary: var(--duration-primary);
--radius: var(--radius-md);
--font-sans: var(--font-sans);
}Each line registers a token with Tailwind: --radius-md: var(--radius-md); inside @theme inline. The inline keyword makes the utility use var(--radius-md) itself instead of a copy.
Everything is registered except the primitive colours you did not keep (option primitives.keep). That is why the example has --color-primitive-white and --color-primitive-black but not the blue and red. The primitives still exist in tokens.css; they only get no utility, so bg-primitive-blue-500 does not exist and bg-primitive-white does.
From this section you get, among others:
| Utility | From | Result |
|---|---|---|
rounded-md |
--radius-md |
border-radius: var(--radius-md) |
font-regular, font-bold
|
--font-weight-* |
font-weight: var(--font-weight-bold) |
font-fa-primary |
--font-fa-primary |
font-family: var(--font-fa-primary) |
bg-primitive-white |
--color-primitive-white |
background-color: var(--color-primitive-white) |
bg-semantic-light-brand-primary |
the light variable | the light colour, in both themes |
:root points each semantic name at its light variable, and .dark points it at the dark one:
:root { --color-brand-primary: var(--color-semantic-light-brand-primary); }
.dark { --color-brand-primary: var(--color-semantic-dark-brand-primary); }The rules:
-
The names come from the light group. One line per light colour, named with the rules in Conversion-Rules.
-
The dark colour is found by name.
Light → Brand → Primary → $rootandDark → Brand → Primaryare bothbrand-primary, whatever the capitals. -
No dark colour means no override. The
.darkblock then holds a comment, and the colour stays as in light:/* --color-status-error: no dark token in Figma — keeps light value */ -
A dark colour with no light one is ignored.
-
If there are no semantic colours and no
fontSans, section 2 is left out. The selectors are the optionsselectoranddarkSelector.
If fontSans is set, :root also gets --font-sans: var(--font-fa-primary); (with your variable name).
An @theme inline block with, in this order:
- one line per semantic colour:
--color-brand-primary: var(--color-brand-primary);→bg-brand-primary,text-brand-primary, … - your
aliases:--color-primary: var(--color-brand-primary);→bg-primary - one
--text-*line per size token, soSize.Bodygivestext-bodyandSize.Heading.Lggivestext-heading-lg - one
--transition-duration-*line per duration token, soDuration.Primarygivesduration-primary - your
extraCSS -
--font-sans: var(--font-sans);whenfontSansis set, sofont-sansuses your font
Point 4 matters: in Tailwind 4.3.3 a --duration-* variable alone does not create a duration-* class, because Tailwind reads --transition-duration-*. Without that line, duration-primary would not exist.
Putting the class dark on an element (normally <html>) switches every semantic colour inside it. The utilities read the variables, so no dark: prefix is needed:
<html class="dark">
<body class="bg-background text-foreground">…</body>
</html>The dark: variant is a different thing. In Tailwind v4 it follows prefers-color-scheme unless you redefine it. If you want dark:bg-card to follow the class as well, add:
@custom-variant dark (&:where(.dark, .dark *));That compiles dark:bg-background to .dark\:bg-background:where(.dark, .dark *); the test suite checks it. If you changed darkSelector, change the variant to match.
@import "tailwindcss";
@import "./generated/tokens.css";
@import "./generated/tailwind.css";tailwind.css needs the variables from tokens.css, so import both.
The utilities the test suite compiles with Tailwind 4.3.3 and checks are bg-primary, text-primary-foreground, bg-background, bg-brand-primary-10, bg-primitive-white, rounded-md, duration-primary, text-body, text-heading-lg, font-bold, font-regular, font-sans, font-fa-primary, and that bg-primitive-blue-500 does not exist.