Skip to content

Style Dictionary

Style Dictionary is great to turn your tokens into CSS and thanks to its open architecture Theemo offers extensions to generate the right formats.

Style Dictionary can generate tokens for multiple platforms (CSS, Android, iOS) but they can also be used to generate tokens for the same platform but under different constraints.

Find them here:

And see the full example to see all of them in action.

Constrained Tokens

For converting tokens with multiple values (Theemo calls them constrained values) two practices have been established for Style Dictionary: Multiple files (one for each constraint) or single file tokens (with multiple values).

Here is a comparison:

CriteriaMulti FileSingle File
KnowledgeKnowledge is with the file itself (filename?)Knowledge stays with the token
ReadingYou see all tokens for one constraintYou see all constrained values for one token
AuthoringBetter at changing values for one constraintBetter changing on a token-by-token basis
BuildingNot all conversion of token into CSS are possible (knowledge is somewhere else)All knowledge is available, every conversion is possible

For most of the time multi vs. single file is a choice of personal flavor and technology can greatly assisst here (using Figma, PenPot or Token Studio). When it comes to token conversion into platform (eg CSS) values, the single file approach shows its advantage, as all the knowledge needed to transform a token already is present on the token.

Theemo supports the idea of constrained values and the provided extensions bring this support into Style Dictionary.

Register Theemo Extensions

To use all provided extension, register them all at once in the config for Style Dictionary (which by default is config.js). Without any constraints being used, the configuration for Style Dictionary is fairly small and straight forward:

config.js
js
import 
StyleDictionary
from 'style-dictionary';
import {
registerTheemo
} from '@theemo/style-dictionary';
registerTheemo
(
StyleDictionary
);
export default {
source
: ['tokens/**/*.json'],
platforms
: {
base
: {
transformGroup
: 'theemo',
buildPath
: 'dist/',
files
: [
{
format
: 'css/variables',
destination
: 'theemo.css',
} ] } } };

With registerTheemo() you have access to the following: