DTCG Tokens

The DTCG format is a W3C Community Group specification started in 2020 and aims to outline a standard, universal design token format that works for all forms of digital design (including web, print, native apps, and beyond).

DTCG tokens are stored in JSON, and look something like the following:

{
  "rebeccapurple": {
    "$type": "color",
    "$value": {
      "colorSpace": "srgb",
      "components": [0.4, 0.2, 0.6]
    }
  }
}

By storing tokens in a universal format like JSON, you can centrally manage them and generate code for any output target including web and native apps.

Types

Currently, the DTCG format defines the following types:

TypeDescription
ColorA flat color.
DimensionA unit for sizing, spacing, etc.
Font FamilyA font family, with fallbacks.
Font WeightA font weight, such as normal or bold.
DurationA unit for time.
Cubic BézierA Cubic Bézier for animations.
NumberA number without units.
Stroke StyleA stroke.
BorderAn element border style.
TransitionA pairing of timing, duration, and a Cubic Bézier to form an animation.
ShadowA drop shadow or inner shadow.
GradientA gradient of colors.
TypographyA complete typographic style, including family, weight, line height, and more.

In addition, Terrazzo also allows 3 additional custom types: Link, Boolean, and String. But it may require writing your own to take full advantage of these types.

Hierarchy

DTCG token files are infinitely-nestable to create your token structure. For example, if you had a color.base.blue.500 token, you’d express it like so:

{
  "color": {
    "base": {
      "blue": {
        "500": { /* … */ }
      }
    }
  }
}

By allowing your JSON structure to nest, you avoid errors by avoiding duplication. For example, if you had to express your tokens like so:

{
  "color.base.blue.100": { /* … */ },
  "color.base.blue.200": { /* … */ },
  "color.base.bleu.300": { /* … */ },
  "color.base.blue.400": { /* … */ },
}

It would be easy to miss the typo of “bleu!” But by declaring every group name once and only once, you make mistakes impossible.

Format

You can find the official format here. But for convenience, we also have a list of token types Terrazzo supports.

Further Reading