@mrzr/figma-tokens
Figma design tokens to CSS variables and a Tailwind v4 theme.
Turn the design tokens you export from Figma into one CSS variable per token, plus a Tailwind CSS v4 theme with the light and dark colours paired for you.
npm install --save-dev @mrzr/figma-tokensnpx @mrzr/figma-tokensinput: tokens
outDir: generated
primitives:
keep: [white, black]
fontSans: font-fa-primary
aliases:
primary: brand-primary
primary-foreground: brand-on-primary
background: neutral-background
foreground: neutral-on-background@import "tailwindcss";
@import "./generated/tokens.css";
@import "./generated/tailwind.css";Now bg-primary, text-primary-foreground and rounded-md work, and class="dark" on <html> switches every semantic colour.
What it does
tokens.css
Every token as a variable on :root. Colours become oklch(), numbers get px or ms, references stay var(--…).
tailwind.css
An @theme inline registration, a :root / .dark pair for semantic colours, your aliases, text-* sizes and duration-* utilities.
--check for CI
Compares what would be written with what is on disk, and exits 1 when they differ.
Honest limits
Composite tokens such as shadows and gradients are rejected with an error instead of guessed.
Is this for you?
Use it if
- Your colours, radii, sizes, fonts and durations are Figma variables you export as JSON
- Your project uses Tailwind CSS v4, or plain CSS variables
- You want light and dark colours wired together without writing the mapping by hand
- You want CI to fail when the tokens change but the CSS was not regenerated
Use something else if not
It writes CSS only. For iOS, Android or other platforms use Style Dictionary directly (this package is built on it). It does not support Tailwind v3 and does not call the Figma API.
Documentation
Everything is documented.
More in design pipeline