Parsers
Parsers are functions allowing you to transform design tokens and assets coming from Specify to fit your needs and company standards.
Last updated
Parsers are functions allowing you to transform design tokens and assets coming from Specify to fit your needs and company standards.
Last updated
By default, without any parsers, Specify will return your design data as raw data:
Design tokens are returned in JSON
Assets are returned as files
There are high chances you need to transform those design data to fit your needs. Parsers help you do just that.
Parsers are functions allowing you to transform design tokens and assets coming from Specify to fit your needs and company standards.
A parser does the following job:
Receives design data as input
Transforms this design data
Returns the transformed data
The data returned by a parser can either be:
Design data that can be used by another parser coming next in your transformation pipeline
A file so it can be used by people, frameworks, or scripts
Parsers are what make Specify powerful and flexible. They help you be in total control of the design data you pull from Specify.
Parsers are ordered and takes specific input to generate specific output. This way, we can easily test the input coming from the previous parser to check if the whole parsers process will work.
Parsers are classified in 2 categories: technology and utility.
Technology parsers help you transform your design tokens to specific technologies and formats (CSS Custom properties, SCSS, Tailwind, a Javascript theme object compatible with React Native...)
Some examples:
Utility parsers take care of "smaller" transformation. Like converting a pixel value to rem
or transforming a string to kebabcase.
Some examples:
All parsers are open source and available on the following GitHub repository.
Replace all the stroke
and fill
attribute raw color value by its corresponding design token as a CSS variable. If no design token match, the raw value will be left as is.
Set a structured filename on your assets. It won't rename your asset but only add a new filename
property on the asset object. The filename structure uses mustache as a template engine.
Transform design tokens to a JavaScript theme
object compatible with React Native.
Generate .scss
files containing Scss map and function / mixin to access the values of the tokens.
Generate Style Dictionary configuration files for all your design tokens coming from Specify.
Format design tokens to create a theme compatible with the TailwindCSS specification.
Format design tokens to create a theme compatible with the theme-ui specification.