Hello everyone,
I started working on migrating my SCSS variables to DTCG tokens for agnosticity purposes. I embraced the DTCG tokens format because it will be the tomorrow standard, and its approach is cross-environmental.
I was amazed by the $extensions properties that support color modes, alternative naming, and more.
This seems not to be working after importing them.
Take this small example:
{
"penpot": {
"color": {
"accent": {
"default": {
"$type": "color",
"$value": "#eef0f2",
"$extensions": {
"mode": {
"penpot-light": "#eef0f2",
"penpot-dark": "#2e3434"
}
}
},
"primary": {
"$type": "color",
"$value": "#6911d4",
"$extensions": {
"mode": {
"penpot-light": "#6911d4",
"penpot-dark": "#7efff5"
}
},
"muted": {
"$type": "color",
"$value": "#e1d2f5",
"$extensions": {
"mode": {
"penpot-light": "#e1d2f5",
"penpot-dark": "#426158"
}
}
}
},
"secondary": {
"$type": "color",
"$value": "#1345aa",
"$extensions": {
"mode": {
"penpot-light": "#1345aa",
"penpot-dark": "#bb97d8"
}
}
},
"tertiary": {
"$type": "color",
"$value": "#8c33eb",
"$extensions": {
"mode": {
"penpot-light": "#8c33eb",
"penpot-dark": "#00d1b8"
}
}
},
...
}
}
}
}
This results on Penpot:
The results are similar on Tokens Studio as they participated in bringing the native tokens to life on Penpot ![]()
The default value is considered, but not those in $extensions.
This approach is quite cutting-edge, but it’s particularly interesting to maintain better control over the token architecture, as every token can be populated with an alternative value that can be interpreted by consuming systems. I took it from Terrazzo, which is an open-source tool that transforms DTCG tokens into styles, created by DTCG members: Modes + Theming ⛋ Terrazzo
How can the $extensions values be managed? Would it create other sets that can be attached to a theme?
For now, I envision using the future API REST (or plugin API) to sync tokens with a Node script, so I’m eager to get started!
Bye!
