This repo is an easy way to get started with Radix UI colors, without having to expose the full selection of scales to the end user and design system consuming designers/developers.
This style dictionary set up follows the Radix approach to composing a color system.
Where pre-defined scales, are mapped to an exposed palette, and this palette is mapped to design system tokens.
{theme} -> scales -> palette -> tokens
yarn
A list of available scales is here.
tokens/color/mapping/palette.json
"palette": {
"core": {
"1": { "value": "{DesiredRadixScaleName.1}", "type": "color" },
}
}
tokens/color/mapping/tokens.json
"neutral": {
"background": {
"value": "{palette.core.1}", "type": "color"
}
}
yarn build
Radix Scales are stored as HSL in JSON and imported on build from these respective locations:
Light theme
Dark theme
This repository generates build files for CSS, Figma and JS. The build task builds out a seperate file for each theme:
- CSS
- dark.css
- light.css
- FIGMA
- dark.json
- light.json
- JS
- dark.js
- light.js
- Raw Style-Dictionary Data
- dark.json
- light.json
Often, you may need to change how color tokens are mapped to the palette for each theme. To do this, simply create a tokens.json
file inside each theme folder.
To create new themes, create a new folder under tokens/color
and add the theme name to themes
array at the top of the config.js file.
const themes = ["light", "dark"];