UI Kit uses style-dictionary to generate our design token distributions. This tool allows us to generate design token distributions for whatever platforms we want.
properties/color/
: properties/color/base.json
is where our full library of colors is stored. All other JSON files in this directory just contain aliases of the colors listed in base.json
.
properties/font/
: the visual attributes of UI Kit's typographic style.
properties/layout/
: values that are used to determine how elements are layed out on the screen. For example: a spacing scale, sizing dimensions, and viewport width breakpoints.
properties/theme/
: the default theme values. At the time of this writing, the only themeable design tokens are colors.
Our JSON files use the Category / Type / Item structure.
{
"color": { <====================================== Category
"base": { <=================================== Type
"purple": { <============================= Item
"lighten": { <======================== Subitem
"1": { "value": "#8360FF" }, <==== State
// ...etc
}
}
}
}
}
The "base" key is ignored when design token variables are generated.
Color names that are not a specific type (e.g.: text, border) follow the pattern Item / Subitem / State
For example: purpleDarken1
Color names that are aliased or of a specific type follow the pattern Type / Category / Item / Subitem
For example: textColorPrimaryInverted
Design tokens related to layout follow the pattern Type / Item
For example: spaceL
Design tokens related to font attributes follow the pattern Category / Type / Item
For example: fontSizeM
npm run build:design-tokens
Uses Amazon Style Dictionary to build design token distributions for JavaScript and LESS.
packages/design-tokens/build/
is for use inside of ui-kitdist/packages/design-tokens/build
is for apps to import ui-kit's design tokens
The build is automatically run before Storybook is built, before tests are run, and before the main ui-kit dist
is built.
The JavaScript and Typescript distribution uses the configuration defined at: packages/design-tokens/config.tsCompiled.json
The LESS distribution uses the configuration defined at: packages/design-tokens/config.manualPublish.json
npm run build:design-token-docs
Uses Amazon Style Dictionary to generate markdown files in design-guidelines/design-tokens to document design tokens.
When design tokens are updated, this script must be run manually to update the documentation.
This build uses the configuration defined at packages/design-tokens/config.designGuidelines.json
.
All of our design tokens are stored in JSON files in the properties/
directory. Our JSON files use the Category / Type / Item structure.
- Check to see if the new design token fits in with a set of tokens in one of the existing JSON files
- If there is no existing JSON file that is appropriate for the new token, create a new JSON file and new directory if necessary.
Design token values can be edited without creating a breaking change. However, editing the name of a design token will cause a breaking change.
UI Kit generates design token distributions for JavaScript (or Typescript), and LESS.
If you want to create a distribution for a new platform, you can use one of style-dictionary's pre-defined formats, or add a custom format to packages/design-tokens/scripts/formats.js
.