Last updated
Was this helpful?
Last updated
Was this helpful?
You can define Color Token values as gradients by writing a css-like syntax. This includes:
Angle of the gradient in degrees (deg for short).
Two or more colors.
The position of each color in percentage.
0%
is the start
100%
is the end
If you'd like a template to explore Gradients with, click the file below to to download the zip folder. Then you can unzip and upload to Tokens Studio in a new Figma file.
Here's an example of how to write the value of a linear gradient with two stops that appear to change colors diagonally (on a 45 degree angle).
To add additional color stops, add them between the round brackets, being sure to define the color value and the position as a percentage.
Here is the same example with a third color stop added exactly at half way between (50%).
You can also Import Color Styles of gradients you've created in Figma to see how they are written in the plugin.
Like Color Tokens with a single value, you can reference another Token in your gradients by adding curly brackets { } around the Token name you want to reference.
Here's an example of a linear gradient with two stops, with colors that appear to change horizontally from light to dark gray:
Like Color Tokens with a single value, you can write the value of your gradients to have colors with reduced opacity by defining each color stop in RGBA.
RGBA colors use a unitless number to define the alpha value, converted into a percentage in Figma. For example:
1
= 100% opacity
0.4
= 40% opacity
0.06
= 6% opacity
Here's an example of a linear gradient with two stops, with colors that appear to change vertically from light with 40% opacity 0.40
to dark gray with 100% opacity 1
:
This also works when your colors are defined as hard-coded values instead of referencing another Token.
Gradients are Color Tokens with multiple values, and can be Exported to Figma as Color Styles. Tokens Studio also supports Styles with Variable References.
Here are some tips for creating Color Styles with Variable References using the Plugin.
When you Export to Figma as Color Styles, select these Options from the menu to create Color Styles with Variable References:
The option for Color styles
is selected.
The option for Create styles with variable references
is selected.
Themes and Token sets where the gradients are located are active
.
Themes and Token sets where the variables are attached are reference only
.
Note that if the Tokens referenced include modified colors that haven't been resolved, the connection to the Variable will not work as expected.
For example, a Token included in the gradient written as rgba({colors.gray.900, 0.5)
will not be connected to the colors.gray.900
variable because the Plugin has not yet resolved the value, written as a 50% opacity in RGBA.
You could create a new Token, for example, gradient-stop
with a value of rgba({colors.gray.900, 0.5)
, then reference the {gradient-stop}
Token in the gradient value instead.
The plugin will support creating Tokens of any CSS Gradients. However, we are not yet able to create all types of gradients in Figma. Unsupported gradient types will be skipped during the import and export with Figma processes.
Linear - Supported
Radial - Requested
Conic - Requested
Positioning a gradient on a layer
In code, gradients are"a special type of image", but Figma doesn't treat them that way.
As design Tokens are intended to be used in code, we are not able to control the position of a gradient on a layer within the plugin in the same way you can in Figma.
The plugin is only able to store the degree of the gradient.
Without any translation information, the positioning of the gradient on a layer cannot be accurately determined.
By default, the plugin applies the gradient to the "edges" of the design element you select when applying the Token.
Today the Plugin isn't able to capture your Variable References when importing your Gradient Color Styles from Figma. It will create the Token with with resolved values as Hex codes.
You can manually replace those values with References to another Token following the steps above↑.
gradient
is an official Token type in the in the W3C Design Token Community Group specifications.(9.6 Gradient)
However, Tokens Studio has yet to support Gradients as an independent Token Type. It is on our radar as we work towards more closely aligning with the DTCG spec.
When transforming Color Tokens with gradient values, there are specific configurations to be aware of.
The SD-Transforms generic package will convert color Token values with Figma's "hex code RGBA" into actual rgba()
format for CSS.
→ SD-Transforms Read-Me Doc, ts/color/css/hexrgba
Color Tokens with gradient values are technically a composite Token as it contains multiple values. Composite Tokens require the SD-Transforms option to expand composite Tokens into multiple Tokens
.
Make sure you look at the generic SD-Transforms package to include this option, which allows you to further customize this transformation further using Style Dictionary.
→ SD-Transforms Read-Me Doc, Using the preprocessor → SD-Transforms Read-Me Doc, Using Expand
Mentioned in this doc:
SD-Transforms - Read Me
Style Dictionary - https://styledictionary.com/
Design Tokens Community Group - W3C Draft
Design Tokens Community Group - 9.6 Gradient
Design in Figma - Paints in Figma, Use Variables in Gradients
9elements.com - Gradient angles CSS Figma and Sketch
Larsenwork - Easing gradients tool
joshwcomeau.com - CSS Gradient Generator
MDN Web Docs - Using CSS Gradients
None yet!
Tokens Studio Plugin GitHub - Open issues for Token Type Gradients
Linear-Gradient Token Does Not Work With Other Color-spaces (Also When Creating Styles/Variables) #2718
Gradients with values in the HSL and P3 color spaces aren't working as expected.
Expand gradient color support - Feature Request
Jump to the guide on Exporting Tokens to Figma by selecting the card below to learn more.
Engineers typically transform Tokens used in code with , which is tool-agnostic. Tokens coming from Tokens Studio require an additional step: , an npm package that prepares Tokens for Style Dictionary.
🐞 If you are experiencing an issue not listed here, please reach out to us on the Troubleshooting channel of our , , or send us an email support@tokens.studio
💡 Something to share?
→ Jump to the Guide on Importing Styles for more details.
💌 Visit to contribute or subscribe to updates.