Re: [community-group] Should the spec include more semantic types? (#104)

Thanks for raising this @mkeftz!

From what I recall, the main reason we've so far focussed on the types of the values rather than what they might be used for, is that the former felt like a much smaller and more manageable set of things to define. The concern was if instead of, say, a single `color` type we had things lie `border-color`, `text-color`, `background-color`, etc. it might be hard to know where to draw the line. "What about `shadow-color`?"  someone might ask. "Why no `highlight-color`?" someone else might ask. And so on. We feared this might put us on a slippery slope to having a set of types that was some kind of superset of all the styling properties CSS, iOS, Android and others support.

But, as you've rightly, noted, it can be useful to provide some additional context that indicates where a token is meant to be used. For instance, design tools could use that to surface those tokens in the appropriate places.

We've mooted the idea of adding a new (optional) token property that could provide hints to tools about what a token should be used for. This is essentially the 2nd option you suggested - i.e. `semanticType` or `usedFor`. The permitted values of that property might be limited to just the most commonly used contexts (such as the ones commonly found in design tools like Figma).

Your first option of having new, semantic types which are aliases for the "plain" types is quite neat too. I think that could be quite elegant.

For the most part I think the difference between semantic type aliases and an additional property that provides to usage hints are stylistic. However, one potential benefit of a separate property is that we could allow it to also be an array of multiple usage hints.

E.g.:

```jsonc
{
  "color": {
    "foreground": {
      "type": "color",
      "value": "#000000",
      "used-for": "text-color" // single purpose
    }
  },
  "size": {
    "large": {
      "type": "dimension",
      "value": "3rem",
      "used-for": [ "margin", "padding", "font-size" ] // multiple purposes
     }
   }
}
```

And I agree that not sollving this in the spec and thus forcing folks to roll their own, bespoke solutions via `extensions` is sub-optimal.

-- 
GitHub Notification of comment by c1rrus
Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/104#issuecomment-1014945818 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 17 January 2022 23:13:17 UTC