コンテンツにスキップ

Rem を px に変換するプリセット

すべてのユーティリティで rem を px に変換します。

ソースコード

インストール

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
  ],
})

使い方

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

オプション

baseFontSize

  • 型: number
  • デフォルト: 16

rem を px に変換する際の基準フォントサイズ (1rem = n px)。

MIT License の下でリリースされています。