Skip to content

Rem to px preset

แปลง rem เป็น px สำหรับ utilities ทั้งหมด

Source Code

การติดตั้ง

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
bash
bun add -D @unocss/preset-rem-to-px
ts
import presetRemToPx from '@unocss/preset-rem-to-px'
import { defineConfig } from 'unocss'

export default defineConfig({
  presets: [
    presetRemToPx(),
    // ...presets อื่นๆ
  ],
})

การใช้งาน

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

Options

baseFontSize

  • Type: number
  • Default: 16

ขนาดฟอนต์พื้นฐานเพื่อแปลง rem เป็น px (1rem = n px)

Released under the MIT License.