@nawt/units
A library for unit conversion and other unit related utilities.
Install
# For NPM
npm install @nawt/units
# For Yarn
yarn add @nawt/units
# For PNPM
pnpm install @nawt/units
API
string
, baseSize: number
)
pxToEm(value: Converts px to em string.
import { pxToEm } from '@nawt/units';
pxToEm('48px'); // returns 3em
string
, baseSize: number
)
pxToRem(value: Converts px to rem string.
import { pxToRem } from '@nawt/units';
pxToRem('48px'); // returns 3rem
string
, baseSize: number
)
emToPx(value: Converts em to px string.
import { emToPx } from '@nawt/units';
emToPx('3em'); // returns 48px
string
, baseSize: number
)
remToPx(value: Converts em to px string.
import { remToPx } from '@nawt/units';
remToPx('3em'); // returns 48px