Replies: 12 comments 18 replies
-
SummaryAt a high level, I think this is worthwhile and would be good-to-have. I would anticipate the big question from many folks would be βis this just the xkcd comic about another standard? will it compete with DTCG?β but I think the advantages here would be:
The only downsides would be something around βanother formatβ but anecdotally given that there arenβt many public formats that try and solve this problem, I see it as filling a gap rather than reinventing the wheel. Detailed feedbackMy knee-jerk opinion related to some details (that Iβm open to changing/revisiting) 1. File FormatJSON, JSON, JSON. JSON5 isnβt a formal spec, and many languages donβt have good parsers. YAML is a contender, but my vote would be JSON (for Terrazzo, we support YAML but only the bits that are serializable to JSON, basically an alternate format). 2. Overall Data Structure(no thoughts; would have more feedback on a specific proposed implementation) 3. Data Structure
4. Interoperabilityπ― yes this could be its own format, and have its own JSON Schema, AND ALSO fit into 5. Tool Maker SupportJust said this, but yes JSON Schema should be table-stakes. There could be a hosted version that just helps the format be consumed anywhere. Aside from that I would probably have more detailed input for an actual JSON Schema spec. Thanks for putting this together! |
Beta Was this translation helpful? Give feedback.
-
|
Just want to chime in here quickly and say as a developer of a popular MCP server for Figma, a common format for design tokens would be immediately valuable to a huge number of my users. Happy to provide more context or information from this side as is helpful, but very much liking the direction @Sidnioulz is thinking in! |
Beta Was this translation helpful? Give feedback.
-
Source attribute discussionopening this thread to avoid mixing convos on @drwpow wrote:
I'm coming up with several ways to understand this proposal. Maybe you're looking at what else could be done with the listing format? E.g. having a listing format generated by Tailwind folks out of a Tailwind theme when there is no Figma/Penpot and no token translation tool in the picture? If so, I'm curious if there are teams out there that would have multiple sources of truth for their design tokens? If not, then they can handle the naming of their source throughout team conventions, free-form documentation, etc. I only see a definite need to have the Could you please share a bit more on what you had in mind? π |
Beta Was this translation helpful? Give feedback.
-
|
Hi, thanks for starting this. I'm very short on time this week so I'm going to keep this pretty brief to start with, and dig into the details a little bit more later. Problem statementSo, if I understand correctly, we need a token interchange format so that tools can better interpret the design token data. The DTCG spec doesn't have enough information and moves too slowly (in part for good reason of course, this is not a critique) to be used as that data format. FormatI think JSON or JSON serializable format is probably best. It remains the most used/standardized data format out there. JSON -> YAML is more reliable than vice versa so if YAML is preferred, this isn't a blocker at all imo. Data StructureMay I suggest using a Flat structure? Example (only 3 props but imagine it with all the other props as well): [
{
"$key": "{colors.red.500}",
"$path": ["colors", "red", "500"],
"$type": "color"
}
]The benefit of this is that you can easily convert it to a Map / HashTable e.g. in JS if you need this: const tokenMap = new Map(arr.map((token) => [token.$key, token]));Which gives you the best of both worlds: easy to iterate (no need to do recursive object traversal), cheap to access an item (vs Array.find()), and also easy to resolve a token reference/alias because the ref matches the key directly. You can also use the path or key to construct a nested object structure. This approach is something that Style Dictionary v5 has been refactored to using internally and it exposes a convertTokenData utility that can help with back & forth conversions between Map, Object and Array: https://styledictionary.com/reference/utils/tokens/#converttokendata So yeah I like the JSON list / array because it's flattened, indexed, JSON serializable and easy to work with out of the box, and also easy to convert to other data structures with a util that already exists in Style Dictionary. From that point onward, it's just about extracting meta data from the $extensions property and translating/moving it to the proposed properties (codeName, designName) for each token item? Style Dictionary format would look something like: import StyleDictionary from 'style-dictionary';
const sd = new StyleDictionary({
source: ['tokens/**/*.json'],
platforms: {
'token-listing': {
transformGroup: 'web', // ensures web compatible values but this can also be handled later in the format
transforms: ['name/kebab'], // kebab casing for "name" prop
files: [{
destination: 'output.json',
format: 'json/token-listing'
}],
}
}
});The implementation of the json/token-listing would be these steps:
Additional notes:
|
Beta Was this translation helpful? Give feedback.
-
|
In our token documentation, I decided to leave it in the hand of the user, which token naming format he wants the design tokens to be displayed, assuming that he mostly is only interested in either one specific naming format. Some normalization and formatting has been needed to achieve this, but it is already possible. Having the token path, from which the token names derive from, split up in an array seems smart to me, because it scales better for all the future formats that might be coming. The same way we want to have a SSOT for the values of our design decisions, we should have a single place, which defines the token name. Further, don't we want to encourage people to really have the same token names E2E? Therefore I don't think that precompiling of the token name in specific design tool or code platform naming formats is the right way to go, because specifying and standardizing, storing and maintaining all these respective properties feels redundant and unnecessarily cumbersome. Regarding the example with tailwind classes vs. CSS variables having the need for different naming transforms, we currently also have that issue, when you want to have different token naming formats for CSS (--kebab-case) and Javascript (lower camel case) output files in Style-Dictionary, which I would consider being all formats of a web platform config. As far as I know there are some plans to rework how (naming) transforms in SD can be applied in a more flexible way, so I would consider it a solved issue and would not take this into account for a possible decision on an universal token name convention. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for this proposal π I'm amazed at how much thought you put into it, and hope to see more of the same along these lines. Supersets of the DTCG format are more than welcome. After all, it is thanks to Sass, Less, and other CSS supersets that CSS is how it is today! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
We currently display our tokens in Storybook with the help of a custom component we built.
As we leverage tokens to deliver multi-branding theming the values on the table will update in real time (along with the computed counterparts) that showcase the updated values. While we could reference our table via the JSON outputted form StyleDictionary we opted for the Screen.Recording.2025-05-08.at.8.00.43.AM.movSome additional things:
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
This comment sums up what's been discussed so far and the remaining other topics. @jorenbroekema, @drwpow, I'd love to hear from you both on the open topics and on how you lean so far in terms of adopting this format (assuming all open questions are resolved, of course) :) Summary of conversation so far1. File FormatWe will use JSON for compatibility with existing DTCG-handling tools and libraries and for consistency with DTCG. 2. Overall Data StructureToken listings would be an object with two properties:
Tip To convert between a dictionary of tokens and a flat array, Style Dictionary already provides JS utilities that can be advertised to tool authors who want to return to a dictionary structure from a token listing file. 3. Data Structure for Listing EntriesThis section discusses how individual entries are encoded and what they contain. Token listings would contain essential token properties: Additional properties are described below in this section. They would be stored through DTCG Names of a token in other platformsIn the discussions, we've uncovered that a design token can have different names in different design tools (e.g. Figma for UI and other tools for marketing/brand work), and different names in code even for a single SD/TZ build (e.g. mixing CSS & Tailwind / mixing SwiftUI & UIKit). So we want to allow multiple names stored in the listing for both code and design. Tools that will consume the listing may want to know the 'type' of each name (e.g. token doc showing only code names for devs; MCP mapping design names to code names). I see two ways we can go about this: a shared a. Shared
|
Beta Was this translation helpful? Give feedback.
-
JSON Schema draftI've published a first draft of the JSON schema based on conversation so far. It will expire at some point in the future as we keep talking, and this is my first schema so it's possible that it contains errors or out-of-date content in the future ;) |
Beta Was this translation helpful? Give feedback.
-
|
Hi folks, time for another status update. TL;DR:
Alpha releaseA release of Token Listing will be available shortly in Terrazzo. We're currently trying to convince our CI to cooperate. It implements everything listed below until "final changes before v1". I've started using token listing in prod with a company that handles multi-product, multi-mode, multi-platform token taxonomies, with tailored token diff, changelog management, QA tools and token documentation. We haven't hit any blockers so far and the format appears to be fit for purpose. More exposure to prod workloads is very, very much welcome. Get in touch on Discord if you need help experimenting with Terrazzo. Schema updatehttps://github.com/Sidnioulz/token-listing/blob/main/listing-v1.0-alpha-3.schema.json Note I'd like to maintain the schema within Terrazzo, just so I don't have too many repos to handle. Format changes
|
Beta Was this translation helpful? Give feedback.
























Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
RFC: Design Token Listing Format
Status updates
Summary
This RFC proposes a joint file format for token translation tools like Style Dictionary (SD format) and Terrazzo (plugin) that would create a listing of design tokens available on a code platform, and the mapping to their equivalent in a design tool (Figma, PenPot, etc, section 3.3 of the W3C draft).
The goal is to establish a common interchange format that bridges tokens as represented in design tools and code implementations, so that engineers can exploit this data to build more tooling that supports collaboration between engineering and design. The type of tool that could consume this format includes:
Below are a few screenshots of what such tools can look like:
France TΓ©lΓ©visions' token doc page where code patterns and Figma names are both printed, using the
docValueanddocType/subtypefields to improve previewBack Market's token doc page built in Storybook that consumes
original.valueto build links between primitive and semantic tokensThe same doc page that uses a weighted search index to improve search results, also including value matches
the Datadog DRUID doc site using different preview renders for different subtypes of the
dimensionDTCG typeFrance TΓ©lΓ©visions' PR assistant used on a repo synchronised with Tokens Studio to showcase the impact of Tokens Studio changes on codebases and spot potential mistakes; built on top of our in-house token diff tool which diffs two token listings
France TΓ©lΓ©visions' token package changelogs built on top of the token diff tool
France TΓ©lΓ©visions' automated release notes built on top of the token diff tool
However this format would not aim to support these tools:
The format would provide an array or tree of design tokens with well-defined attributes that tool makers can look for and choose to use. The attributes would map code-related, design-tool-related and possibly doc-related concerns in a single file.
Rationale
While I'm aware of the work being done on the W3C specification, there's an immediate need for a practical format that tools can use today to share token information across the ecosystem. The design system community currently lacks explorations of what can be achieved with design tokens beyond just delivering them as code artefacts.
A joint format available in the two main token translation tools, that addresses most known use cases, would encourage developers to experiment and build their own scripts and tools. In turn, these tools would help grow our collective understanding of potential interoperability needs beyond what's already standardised. That would support the DTCG's goal to build standards that meet the needs of our community, in an area that remains largely unexplored for the moment.
Discussion Points
In the below sections, "token listing" refers to the file format proposed by this RFC.
1. File Format
The DTCG format uses JSON as a file format, meaning tools that manipulate tokens right now know how to manipulate JSON files. Arguments in favour of JSON are available in the draft report.
Formats like JSON5 or YAML would arguably allow comment support, but the token listing file is expected to be consumed by machines, not humans.
A binary format could improve uncompressed size, but would greatly complicate interoperability over JSON. It's also likely that JSON token listings would compress very well.
2. Overall Data Structure
This section discusses how entries in the listing are presented.
Options:
Nested tree structure
Pros:
Cons:
Flat array of tokens
Pros:
Cons:
Flat Object
Pros:
Cons:
3. Data Structure for Listing Entries
This section discusses how individual entries are encoded and what they contain.
All proposed properties below should have their name challenged. All should be stored through DTCG
$extensions. THis will allow DTCG tokens to be a valid subtype for listing entries, so that existing code that manipulates individual tokens can be used to manipulate listing entries if needed.Token listings would also contain essential token properties defined in the DTCG:
In all likelihood, token listings would not preserve group information. This information is not relevant to most use cases, and while it could sound relevant to documentation, my experience is that token grouping in doc is done differently than in source token files as it's often thought through after a token taxonomy has been deployed to production.
designNameThe name of the token in Figma, PenPot, etc.
Rationale
Always different from the encoded DTCG name, this name is useful to display in documentation.
For instance, devs using Figma without DevMode can copy a Figma variable name, go to their token documentation website, paste it in the in-page find of their browser token documentation, and obtain the equivalent code name.
Designers may also inspect a component's code in browser DevTools or a Pull Request UI, and go through the same process to find the equivalent design name. They may then search it up in their design tool to ensure the right token was used.
Uses
codeNameRepresents the exact code string used to query a design token. In many cases, token names can be transformed to
codeNames, but not always.Rationale
In some CSS-in-JS stacks, the code rendered by token translation tools will be an object structure fed to the config file of the CSS-in-JS tool. Then, developers will access the token using a getter, e.g.
theme('bg.primary').In iOS stacks, some teams prefer to build custom data structures with dedicated getters that can be used in both SwiftUI and UIKit, while others prefer to use distinct enums for each framework. Whenever I've had to implement such stacks, I've had to use token names to build the data structures, and have needed a different attribute to hold the final string used in XCode to query the corresponding token.
Uses
Notes
It's possible that in some stacks, several code patterns exist to query a token based on where it is consumed. Counter-examples to my proposal are welcome here.
docTypeorsubtypeRepresents a more specific subtype of the token's type, which can be used to visually represent it. Not an essential property for the viability of token listings.
Rationale
In another (paused) project, I audited how various tailored token documentations represent tokens of a given type. Those documentations use several visual representation especially for color and dimension tokens.
An optional
subtypefield could be set on listing entries so that documentation tools know how to display the token. Identified subtypes so far would be:Uses
Notes
Note that the role of the listing format here is just to transport the information if available in a token's
$extensions. The mapping of DTCG types to optional subtypes can be done through multiple attribute transforms / plugins that read e.g.bg,fg,paddingand so on in token names/paths. This would enable teams with custom type mapping logics to rely on the listing for transport and on their own custom code to perform mapping.Still, having subtypes that map observed needs (both in doc sites and design tools) would make this field more useful to include in listings.
docValueorwebSafeValueAn explicitly Web-compatible value for the token's
$valuefield.Rationale
May sound like a niche need, but tokens transformed for mobile or other non-Web platforms have a
$valuethat can no longer be displayed in a Web doc page. IDE plugins, data formats like Slack Blocks, GitLab and GitHub Pull Request comment UIs are also likely to be able to prevent a web-safe value rather than the actual value of a token.Uses
valueReferenceakaoriginal.valuein SDThe untransformed value of the token, containing unresolved aliases/references, or alternatively, a data structure that's set only when a value had an alias, to the alias that was resolved.
Rationale
Helps documentation tools showcase semantic vs core/primitive tokens separately, and build navigation links between them.
Helps token diff tools showcase when a token's value was changed to a new alias even if the resolved value didn't change (e.g. fixing wrong semantic->primitive mappings, or making changes to a token taxonomy).
Uses
4. Interoperability & Future-Proofness
To ensure the listing format does not compete with the DTCG format, I want it to use the
$extensionmechanism. I'm also keen to keep all the above data points optional in the format spec so that tool makers must preemptively handle missing data, should some of it found its way into a future version of the DTCG format and become redundant.However, one thing I don't know how to address yet is versioning of the token listing format. Do you folks consider it necessary or only nice-to-have? Is it important enough to justify complicating the file format (e.g.
{ meta: { listingVersion: 1, ... }, data: [<actual listing data>] })?I'm also curious to have your opinions whether this is too specialised to be discussed in the DTCG group or whether the conversation should be happening there, with potential standardisation in the long run. My personal goal is for us to have a crutch now that does not require any commitment by the DTCG editors, so we can learn from what comes out of it and standardise whatever-else works best later, but I'm open to moving this to the DTCG GitHub if folks here consider it valuable already.
5. Tool Maker Support
Should helpers be provided to tool makers who intend to use the token listing format, e.g.
6. Proposed Next Steps
From there on I'd be a step closer to open-sourcing the token diff script we built with my teammates, and I'd be able to help the Figma MCP maintainer improve token translation support in his tool.
Looking forward to reading your thoughts!
Beta Was this translation helpful? Give feedback.
All reactions