PricingBlog

Create dynamic spacing style variable?

  • tomthebigtree-1278267014200164444

    Tom Ireland

    1 year ago

    I'd like to be able specify a style variable for height and width of an element and have that be divided by 16px (the base) for rem calculation so it can be used across different elements.

    I know I can add individual element style variables and use a formula to calculate the rem value but I need to do this for every element. It would be great if I could just have height and width be calculated by a formula so that I punch in the pixel value and it calculates the rem for me.

    Is that possible?
    1
  • max.kayr-1278399682560790561

    Max

    1 year ago

    I am not sure I understand what you want to do 🧐
  • Can you add a screenshot or one of your nice short videos you do?
  • tomthebigtree-1278403751777927189

    Tom Ireland

    1 year ago

    No worries, @Max 🙂

    https://youtu.be/-XWYpkwNhGM
  • max.kayr-1278407020168482866

    Max

    1 year ago

    Ah, I don't think you can do that globally. You would have to do the calculation in another tool (a calculator, I guess 😅) and hard code the values into the theme. Or add the style variables to each element, as you are doing at the moment...
  • tomthebigtree-1278407295449169991

    Tom Ireland

    1 year ago

    Ach, that's a shame. Ho, hum! 😄
    😄1
  • Have that in another tab and just hard code values lol
  • It's also another thing to have to calculate. I know it's minimal but little things add up right?
  • tomthebigtree-1278432745046937601

    Tom Ireland

    1 year ago

    Thanks, pal! 🙂