Created
February 16, 2022 02:38
-
-
Save daltonmenezes/9cac0767af3d248eddc61e8a57b2b44d to your computer and use it in GitHub Desktop.
A pixel to rem utility function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pixelToRem(...values: number[]) { | |
return values | |
.reduce((acc, current) => (acc += current / 16 + `rem `), "") | |
.trim(); | |
} | |
pixelToRem(13, 20) // 0.8125rem 1.25rem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very nice!