mixin-dictionary
CSS variables, LESS/SCSS variables and mixins from design tokens in the DTCG or Style Dictionary format, with light, dark and other themes.
mixin-dictionary builds CSS variables, LESS and SCSS variables and mixins from design tokens: text styles, media queries and keyframes. It is based on Style Dictionary and is used to build pbstyles.
Resources: npm · GitHub · Changelog · Playground.
Why this package
- JSON config, no code. One
config.json, no JS/TS build script. - DTCG and the legacy format. Reads W3C Design Tokens (DTCG 2025.10) (
$value,$type, compositetypographyandshadow) as exported by Figma, Tokens Studio and Terrazzo, and the legacy Style Dictionary format (value) with the same output. - Themes on any DOM level. Light, dark and other themes switch with the
data-themeattribute on<html>or on a nested container. LESS and SCSS variables of semantic tokens point to CSS variables, so the theme switches without a rebuild.
Quick start
npm install --save-dev mixin-dictionary{
"$schema": "./node_modules/mixin-dictionary/schema/config.schema.json",
"platforms": ["css", "less", "scss"],
"source": ["tokens/*.json"],
"output": "./styles"
}npx mixin-dictionaryThe result goes to styles/css/index.css, styles/less/index.less and styles/scss/index.scss:
@import './styles/scss/index.scss';
.title {
@include h64;
}
@include lg {
.sidebar {
display: none;
}
}Sections
Config and CLI
config.json fields, platforms, command-line flags, what goes into each file.
DTCG tokens
The new format: $value, $type, mixins from typography, breakpoints and keyframes without the mixin field.
Legacy format
Style Dictionary tokens with the value field and mixins via the mixin field.
Themes
Light, dark and other themes for CSS, LESS and SCSS, data-theme on any element.
API and watch mode
build() and generate() from code, TypeScript types, rebuild on token changes.
Playground
Build the result from your own tokens right in the browser, with nothing to install.
What's new in 1.6
- DTCG 2025.10 input and composite
typographyandshadowtokens. - Mixins of text styles, breakpoints and animations are built without the
mixinfield. - Any number of themes and
themes.default. - Programmatic API, TypeScript types, JSON Schema of the config and
--watch. - Clear one-line errors with the token path and the file name.
Configs and tokens of version 1.4 work without changes. The output differs only for token paths in camelCase or with _: before, the variable and the mixin got different names, now the names match. The full list of changes and fixes is in the CHANGELOG.