0.3.0 • Published 1 year ago

@unocss-applet/preset-rpx-to-rem v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@unocss-applet/preset-rpx-to-rem

Coverts rem to rpx for utils.

Instal

npm i @unocss-applet/preset-rpx-to-rem --save-dev # with npm
yarn add @unocss-applet/preset-rpx-to-rem -D # with yarn
pnpm add @unocss-applet/preset-rpx-to-rem -D # with pnpm

Usage

import { defineConfig } from 'unocss'

import presetRpxToRem from '@unocss-applet/preset-rpx-to-rem'

export default defineConfig({
  presets: [
    // ...
    presetRpxToRem({ baseFontSize: 16, screenWidth: 375 }),
  ],
})

Type Declarations

export interface RpxToRemOptions {
  /**
   * 1rem = n px
   * @default 16
   */
  baseFontSize?: number

  /**
   * screen width in px
   * @default 375
   */
  screenWidth?: number
}
<div class="p-32rpx"></div>

without

.p-32rpx {
  padding: 32rpx;
}

with

.p-32rpx {
  padding: 1rem;
}

License

MIT License © 2022-PRESENT Neil Lee