Skip to content

Rem to px preset

Converts rem to px for all utilities.

Source Code

Installation

bash
pnpm add -D @unocss/preset-rem-to-px
bash
yarn add -D @unocss/preset-rem-to-px
bash
npm install -D @unocss/preset-rem-to-px
uno.config.ts
ts
import presetRemToPx from '@unocss/preset-rem-to-px'
import { defineConfig } from 'unocss'

export default defineConfig({
  presets: [
    presetRemToPx(),
    // ...other presets
  ],
})

Usage

html
<div class="m-2"></div>
css
.m-2 {
  margin: 0.5rem;
}
css
.m-2 {
  margin: 8px;
}

Options

baseFontSize

  • Type: number
  • Default: 16

The base font size to convert rem to px (1rem = n px).

Released under the MIT License.