unocss-unit-to-vw
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

unocss-unit-to-vw

Convert all rem/px to vw in utils

Install

npm install --save-dev unocss-unit-to-vw

Usage

Options

// rem to vw options
interface RemToVwOptions {
	baseFontSize?: number // defalut 16
	baseWidth?: number // defalut 375
	unitPrecision?: number // defalut 4
}

Config

import { defineConfig } from 'vite'
import UnoCSS from 'unocss/vite'
import { presetUno } from 'unocss'
import presetRemToVw from "unocss-unit-to-vw"

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    UnoCSS({
      presets: [
        presetUno(),
        presetRemToVw()
      ],
    }),
  ],
})

without

.m-2 {
  margin: 0.5rem;
}

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

with

.m-2 {
  margin: 2.1333vw;
}

.m-8px {
  margin: 2.1333vw;
}

Dependencies (1)

Dev Dependencies (7)

Package Sidebar

Install

npm i unocss-unit-to-vw

Weekly Downloads

16

Version

0.0.8

License

MIT

Unpacked Size

5.8 kB

Total Files

6

Last publish

Collaborators

  • elonehoo