Using tokens in code
The Elements team maintains the design tokens in JSON in the elements/tokens folder of the Elements repository.
The tokens get transpiled into the formats consumed by elements/themes and elements/components.
To use the tokens, enter the following command in your terminal:
npm install @springernature/elements
Then you can reference tokens using their Sass variable names:
- alias:
$t-a-… - component:
$t-eds-c-…
Theme values resolve automatically depending on which theme’s stylesheet is loaded. The same component markup and token references work for different brands. See Get started for how to import a theme.
Do not hard code a hex, px, rem, or other value in component styles where a token already exists for that purpose. This is the most common cause of inconsistency between design and code.
Process for requesting a new token
- Check existing tokens. Review the available design tokens and use an existing token wherever possible.
- Identify the gap. If your requirement cannot be met by an existing token, document why and provide an example.
- Raise it for discussion. Raise the request in the Ask Elements Teams channel.
- Review and approval. The Elements team will work with you to decide whether the new token should be added to the system.
Deprecation and migration
To retire a token, mark it deprecated and keep it in place for that release. Document the replacement alias and update components and product styles to use it. Remove the deprecated token in a later release, once consumers have moved.
Removing a token in the same change that introduces its replacement will break existing Sass. Keep the deprecated token available until the migration is done.
Help improve this page
If you have a question, idea, or suggestion to improve this component or guidance, post in the Ask Elements Teams channel.