develop

Design tokens

One way to bring them all.

Design tokens are constant and platform-agnostic shared values. This set of data-value dictionary is used to ensure a better consistency across different platforms and digital products, plus it solve the issue of hardcoding common values inside the code over and over.

Usage

Wanda's design tokens are generated for different platforms, this means that from a single source of truth — containing informations about colors, space, fonts, and more — we can generate platform-specific files which you can import and use.

For the web platform we provide two ways to use Wanda's design tokens, you can access them inside javascript or css by importing the relative file from the correct node_modules path.

CSS

Then you can get the tokens by using the token() notation as in the following example. Note that custom environment variables are replaced with the final token value at build-time, so they are not dynamic like custom properties.

.MyCustomComponent {
  padding: token(--space-8);
  border-radius: token(--radius-24);
  color: hsl(token(--color-red-20) / 20%);
}

css

As you may noticed color tokens are shipped as hsl colors but without the css hsl() notation. This is useful to handle different opacities by using the level 4 color module syntax like in the example above.

If you want to use the tokens in your code without using the PostCSS plugins, you can also import the css file directly and use the tokens as standard custom property:

@import "@wonderflow/tokens/platforms/web/tokens.css";

css


About css tokens

If you're using the Wanda's postcss shared configuration tokens are already available inside CSS, you don't need to import them.

Javascript

Design tokens are also available in JSON format, which you can import and use in your javascript code.

import tkns from "@wonderflow/tokens/platforms/web/tokens.json";

export const Component = () => (
  <div style={{ color: `hsl(${tkns.color.blue[70]})` }} />
);

jsx

Tokens list

{
  "color": {
    "blue": {
      "0": "180 100% 95%",
      "5": "187 100% 89%",
      "10": "200 100% 83%",
      "20": "206 72% 67%",
      "30": "210 60% 54%",
      "40": "214 66% 44%",
      "50": "217 80% 35%",
      "60": "219 93% 27%",
      "70": "221 100% 22%",
      "80": "222 100% 17%",
      "90": "223 100% 12%",
      "100": "223 100% 7%"
    },
    "cyan": {
      "0": "186 100% 96%",
      "5": "187 69% 85%",
      "10": "187 65% 74%",
      "20": "187 57% 58%",
      "30": "187 52% 48%",
      "40": "187 60% 40%",
      "50": "187 64% 33%",
      "60": "187 66% 27%",
      "70": "187 66% 22%",
      "80": "186 67% 18%",
      "90": "187 66% 15%",
      "100": "186 64% 12%"
    },
    "dipsy": {
      "0": "81 55% 94%",
      "5": "82 54% 84%",
      "10": "83 53% 74%",
      "20": "83 54% 64%",
      "30": "83 54% 49%",
      "40": "83 56% 43%",
      "50": "83 60% 38%",
      "60": "83 60% 32%",
      "70": "83 80% 24%",
      "80": "82 80% 20%",
      "90": "82 68% 17%",
      "100": "84 77% 12%"
    },
    "green": {
      "0": "149 100% 91%",
      "5": "145 95% 84%",
      "10": "145 76% 75%",
      "20": "146 62% 59%",
      "30": "147 63% 46%",
      "40": "149 83% 35%",
      "50": "152 100% 28%",
      "60": "156 100% 23%",
      "70": "160 100% 18%",
      "80": "166 100% 13%",
      "90": "170 100% 8%",
      "100": "177 100% 4%"
    },
    "indigo": {
      "0": "240 60% 98%",
      "5": "240 60% 95%",
      "10": "240 57% 90%",
      "20": "240 58% 85%",
      "30": "240 52% 74%",
      "40": "241 60% 63%",
      "50": "241 60% 56%",
      "60": "242 60% 48%",
      "70": "241 60% 38%",
      "80": "241 61% 27%",
      "90": "241 61% 16%",
      "100": "240 61% 12%"
    },
    "magenta": {
      "0": "327 73% 97%",
      "5": "324 70% 91%",
      "10": "324 70% 84%",
      "20": "324 70% 74%",
      "30": "324 60% 64%",
      "40": "324 60% 44%",
      "50": "324 70% 38%",
      "60": "324 70% 31%",
      "70": "324 70% 25%",
      "80": "323 71% 20%",
      "90": "324 71% 16%",
      "100": "324 70% 12%"
    },
    "mint": {
      "0": "165 62% 95%",
      "5": "165 61% 90%",
      "10": "165 60% 82%",
      "20": "166 59% 71%",
      "30": "166 60% 55%",
      "40": "166 60% 40%",
      "50": "165 60% 35%",
      "60": "165 59% 30%",
      "70": "165 61% 24%",
      "80": "165 63% 17%",
      "90": "166 64% 13%",
      "100": "166 61% 10%"
    },
    "primary": {
      "0": "210 20% 98%",
      "5": "220 19% 91%",
      "10": "220 16% 85%",
      "20": "219 14% 75%",
      "30": "220 12% 66%",
      "40": "221 10% 56%",
      "50": "221 9% 49%",
      "60": "221 10% 39%",
      "70": "221 10% 30%",
      "80": "219 13% 22%",
      "90": "218 11% 14%",
      "100": "225 11% 7%"
    },
    "purple": {
      "0": "300 100% 98%",
      "5": "298 94% 93%",
      "10": "299 65% 87%",
      "20": "298 47% 75%",
      "30": "297 39% 64%",
      "40": "298 32% 54%",
      "50": "298 32% 46%",
      "60": "298 35% 38%",
      "70": "298 38% 31%",
      "80": "298 41% 25%",
      "90": "297 42% 18%",
      "100": "298 43% 12%"
    },
    "red": {
      "0": "343 100% 96%",
      "5": "351 100% 88%",
      "10": "351 100% 81%",
      "20": "351 77% 64%",
      "30": "351 66% 49%",
      "40": "351 92% 37%",
      "50": "351 100% 31%",
      "60": "351 100% 25%",
      "70": "351 100% 20%",
      "80": "350 100% 15%",
      "90": "350 100% 10%",
      "100": "351 100% 5%"
    },
    "salmon": {
      "0": "16 73% 97%",
      "5": "15 70% 91%",
      "10": "15 70% 83%",
      "20": "15 69% 77%",
      "30": "15 70% 68%",
      "40": "14 70% 60%",
      "50": "14 63% 53%",
      "60": "15 66% 45%",
      "70": "15 70% 37%",
      "80": "14 70% 29%",
      "90": "14 69% 19%",
      "100": "14 70% 12%"
    },
    "support": {
      "brand": "0 100% 47%",
      "black": "0 0% 0%",
      "white": "0 0% 100%"
    },
    "violet": {
      "0": "257 47% 97%",
      "5": "263 51% 92%",
      "10": "262 50% 85%",
      "20": "263 50% 75%",
      "30": "263 50% 62%",
      "40": "263 50% 49%",
      "50": "263 50% 40%",
      "60": "262 50% 34%",
      "70": "262 49% 30%",
      "80": "262 50% 24%",
      "90": "263 50% 18%",
      "100": "263 51% 12%"
    },
    "yellow": {
      "0": "60 100% 89%",
      "5": "46 100% 83%",
      "10": "38 100% 77%",
      "20": "31 89% 65%",
      "30": "28 72% 53%",
      "40": "26 82% 42%",
      "50": "25 100% 34%",
      "60": "24 100% 29%",
      "70": "22 100% 24%",
      "80": "22 100% 19%",
      "90": "22 100% 15%",
      "100": "21 100% 10%"
    }
  },
  "breakpoint": {
    "extra-small": "30em",
    "small": "48em",
    "medium": "60em",
    "large": "80em",
    "extra-large": "100em"
  },
  "container": {
    "large": "90.00rem",
    "medium": "62.50rem",
    "small": "40.00rem"
  },
  "icon": {
    "size": {
      "12": "0.75rem",
      "16": "1.00rem",
      "18": "1.13rem",
      "24": "1.50rem",
      "32": "2.00rem",
      "40": "2.50rem",
      "48": "3.00rem",
      "56": "3.50rem"
    }
  },
  "radius": {
    "4": "0.25rem",
    "8": "0.50rem",
    "16": "1.00rem",
    "24": "1.50rem",
    "32": "2.00rem",
    "40": "2.50rem",
    "48": "3.00rem"
  },
  "space": {
    "2": "0.13rem",
    "4": "0.25rem",
    "8": "0.50rem",
    "16": "1.00rem",
    "24": "1.50rem",
    "32": "2.00rem",
    "40": "2.50rem",
    "48": "3.00rem",
    "56": "3.50rem",
    "64": "4.00rem",
    "72": "4.50rem",
    "80": "5.00rem",
    "88": "5.50rem",
    "96": "6.00rem",
    "104": "6.50rem",
    "112": "7.00rem",
    "120": "7.50rem",
    "128": "8.00rem",
    "136": "8.50rem",
    "144": "9.00rem",
    "152": "9.50rem",
    "160": "10.00rem",
    "168": "10.50rem",
    "176": "11.00rem",
    "184": "11.50rem",
    "192": "12.00rem",
    "200": "12.50rem"
  },
  "duration": {
    "100": "0.10s",
    "200": "0.20s",
    "250": "0.25s",
    "300": "0.30s",
    "500": "0.50s",
    "750": "0.75s",
    "1000": "1.00s"
  },
  "easing": {
    "standard": "cubic-bezier(0.3, 0.07, 0.34, 1)",
    "entrance": "cubic-bezier(0, 0, 0.34, 1)",
    "exit": "cubic-bezier(0.3, 0.07, 1, 1)"
  },
  "font": {
    "family": {
      "sans": "system-ui, sans-serif",
      "mono": "monospace"
    },
    "lh": {
      "standard": 1.5,
      "small": 1.2
    },
    "size": {
      "14": "0.88rem",
      "16": "1.00rem",
      "18": "1.13rem",
      "22": "1.38rem",
      "28": "1.75rem"
    }
  }
}

json


Created and maintained by Mattia Astorino for Wonderflow.

© Wonderflow 2022