Conversion from px to rem #7785
federicocappellotto97
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
You can add this to the top of your const BASE = 16; // your base size
const rem = (px, key = px) => ({ [key]: `${px / BASE}rem` }); You can then use as so:
You can then use I'm trying to track down where first saw this technique. I'll update once I locate. |
Beta Was this translation helpful? Give feedback.
2 replies
-
How about custom ones like |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I develop websites based on layouts made with XD, Figma ecc.. and every size is in pixel, so i need to convert them in rem everytime. For example if a text has font-size: 18px, i use text-[1.125rem] . It would be very cool and useful to have a function that made the conversion automatically, for example text-[rem(18px)] that create the rule font-size: 1.125rem
Beta Was this translation helpful? Give feedback.
All reactions