Skip to content

Tokens

Token architecture

Use tokens, not raw values, for every color, size and duration.

Tokens
538 in three tiers
Formats
CSS custom properties, SCSS, JSON

Three tiers

The three token tiers
TierExampleUse it
Primitive--sg-color-blue-600Never directly. Other tiers point to it.
Semantic--sg-color-text-secondaryIn your own layouts and components.
Component--sg-button-primary-backgroundTo change one component everywhere.

How one value resolves, in each theme:

Using tokens

Set data-theme="dark" or data-density="dense" on <html> or any element. See Theme and density.

Names

Naming pattern by tier
TierPatternExamples
Primitive--sg-{category}-{family}-{step}--sg-color-blue-600, --sg-space-4
Semantic--sg-{category}-{role}-{variant}-{state}--sg-color-action-primary-hover, --sg-space-inset-control
Component--sg-{component}-{variant}-{property}-{state}--sg-button-primary-background-hover, --sg-table-row-selected

Color tokens

Other tokens are on Spacing and density, Typography, Elevation and shape and each component page.

Actions

Text

Surfaces

Borders

Feedback

Focus

Files

tokens/tokens.json is the source. tokens.css and _tokens.scss are generated; do not edit them.

Changing a token

Edit tokens/tokens.json, then run node tools/build.mjs. It regenerates every file and lists any failures. Mark a token $deprecated before removing it.

Build checks

Build checks
CheckRule
DescriptionsEvery token has one.
ReferencesEvery referenced token exists.
ContrastDeclared color pairs meet their target in light and dark.
GraysNeutrals have no tint.
SpacingOn the 4pt grid, 64px at most.
Component CSSNo hard-coded colors, off-grid lengths or undefined tokens.
TypeOne font family; weights 400 and 600.
IconsEvery used icon is in the set.
NamingThe product is called Stingray or Stingray 1.