- From: James Nash via GitHub <sysbot+gh@w3.org>
- Date: Tue, 28 Mar 2023 13:51:36 +0000
- To: public-design-tokens-log@w3.org
The design tokens defined in a DTCG file are intended to be platform agnostic. It's the job of a translation tool (like [Style Dictionary](https://amzn.github.io/style-dictionary/) or [Cobalt](https://careers.jpmorgan.com/us/en/professionals)) to convert those tokens into code. Part of that translation may include converting the DTCG units into whatever the platform-specific equivalents are. As you've noted, the `px` unit in a DTCG file is equivalent to `dp` on Android, so a token value like `32px` would probably get exported as `32dp`. > The sp unit is the same size as a dp, by default, but it resizes based on the user's preferred text size > (source: https://developer.android.com/training/multiscreen/screendensities) So an Android `sp` is the same kind of concept as CSS `rem` (which is the other permitted dimension unit in DTCG files), except that it's relative to 1dp rather than the base font size like `rem` is in CSS. Therefore: `1rem` == `16sp`. So to have design tokens that would get exported as `sp` values in Android, use the `rem` unit and divide your value by 16. For example: `{ "$value": "2rem", "$type": "dimension" }` should be exported to `32sp` on Android. -- GitHub Notification of comment by c1rrus Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/208#issuecomment-1486930153 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 28 March 2023 13:51:39 UTC