Skip to content
Discussion options

You must be logged in to vote

Digging into the examples, the following transform assumes that the incoming size will be a number and appends px to it. In my case, it was coming in as 6rem which got converted into 6px - obviously not correct.

I am starting to think that the best approach may be to specify all sizes as unit-less numbers in Figma representing pixels, and then converting them to rem, em etc. in platform specific transformers. Am I thinking in the right direction?

StyleDictionary.registerTransform({
  name: 'sizes/px',
  type: 'value',
  matcher: function (prop) {
    // You can be more specific here if you only want 'em' units for font sizes
    return [
      'fontSize',
      'spacing',
      'borderRad…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@six7
Comment options

six7 Mar 16, 2022
Maintainer

@nareshbhatia
Comment options

Answer selected by nareshbhatia
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants