Design Tokens
Last updated
Was this helpful?
Last updated
Was this helpful?
A design token is an underlying object that is a base for the following object types:
Design tokens carry one piece of atomic information (such as color) either as a raw value or as a reference to other tokens (for example, a token defining primary-cta
might be inherited by many color tokens that have a different semantic purpose, such as button-main)
. This allows you to change one color and propagate the change to all colors that share the reference.
Each token always defines the base information such as name, description, or type. Extra to that, each token also carries its value inside value
property:
In order to avoid duplication, Supernova introduces the concept of referencing and aliases - shared values that are defined once but then referenced throughout the design system.
If a token reference is used, the token payload will give you that information as well. This is useful if you really want to export the entire chain as it was defined, not just the raw values.
All tokens are automatically resolved for your convenience, but each property always contains referencedToken
property so you know when the value comes from a reference. You don't have to worry about circular references, as Supernova prevents the creation of them.
When the token was defined as value without reference, referencedToken
will be null
.
Many functions will ask you for token type. Following is the reference list of all token types available:
Color
- for color tokens
Font
- for font tokens
Gradient
- for shadow tokens
Shadow
- for shadow tokens
Border
- for border tokens
Radius
- for radius tokens
Measure
- for measure tokens
Typography
- for typography tokens
Text
- for text tokens
You can use this type to know what type of token was retrieved or as a filter in certain functions, such as:
This will fetch only tokens of type Color
, and ignore everything else.
The TokenValue
differs based on what type of token it is. For example, the full definition for will look like this: