Tokens
Token architecture
Use tokens, not raw values, for every color, size and duration.
Three tiers
| Tier | Example | Use it |
|---|---|---|
| Primitive | --sg-color-blue-600 | Never directly. Other tiers point to it. |
| Semantic | --sg-color-text-secondary | In your own layouts and components. |
| Component | --sg-button-primary-background | To 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
| Tier | Pattern | Examples |
|---|---|---|
| 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
| Check | Rule |
|---|---|
| Descriptions | Every token has one. |
| References | Every referenced token exists. |
| Contrast | Declared color pairs meet their target in light and dark. |
| Grays | Neutrals have no tint. |
| Spacing | On the 4pt grid, 64px at most. |
| Component CSS | No hard-coded colors, off-grid lengths or undefined tokens. |
| Type | One font family; weights 400 and 600. |
| Icons | Every used icon is in the set. |
| Naming | The product is called Stingray or Stingray 1. |