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, composite typography and shadow) 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-theme attribute 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-dictionary

The 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

What's new in 1.6

  • DTCG 2025.10 input and composite typography and shadow tokens.
  • Mixins of text styles, breakpoints and animations are built without the mixin field.
  • 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.