chenxch / unocss-preset-pxtorem

Convert all px to rem in utils

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unocss-preset-pxtorem

Coverts px to rem for utils.

Support simultaneous use with vant.

Installation

npm i -D unocss-preset-pxtorem
import presetPxToRem from 'unocss-preset-pxtorem'

Unocss({
  presets: [
    presetPxToRem()
  ],
})

Config

presetPxToRem(options: PxToRemOptions = {})

interface PxToRemOptions {
  /**
   * 75px = 1 rem
   * @default 75
   */
  rootValue?: number
  /**
   * precision
   * @default 5
   */
   unitPrecision?: number
}

Usage

<div class="m-75px" w-35px></div>

without

.m-75px {
  margin: 75px;
}

.w-35px{
  width: 35px;
}

with

.m-75px {
  margin: 1rem;
}

.w-35px{
  width: 0.46667rem;
}

License

MIT License © 2022-PRESENT Xc

About

Convert all px to rem in utils

License:MIT License


Languages

Language:TypeScript 100.0%