Skip to content

傳統兼容性預設

傳統兼容性實用工具集合。

此預設不包含任何規則,它對來自其他預設的生成的 CSS 應用後處理。

默認情況下,沒有啟用任何選項,你需要顯式選擇加入每個選項。

源代碼

安裝

bash
pnpm add -D @unocss/preset-legacy-compat
bash
yarn add -D @unocss/preset-legacy-compat
bash
npm install -D @unocss/preset-legacy-compat
ts
// uno.config.ts
import { defineConfig } from 'unocss'
import presetLegacyCompat from '@unocss/preset-legacy-compat'

export default defineConfig({
  presets: [
    // ...其他預設
    presetLegacyCompat({
      // 選項
      commaStyleColorFunction: true,
    }),
  ],
})

選項

commaStyleColorFunction

  • 類型: boolean
  • 默認值: false

將顏色函數(rgb()hsl())從空格分隔轉換為逗號分隔,以提高對舊版瀏覽器的兼容性。恢復 UnoCSS v0.57.0 之前的舊行為,該行為在 #3221 中更改為空格分隔以與 Tailwind CSS 對齊。

示例:

  • rgb(255 0 0) -> rgb(255, 0, 0)
  • rgb(255 0 0 / 50%) -> rgba(255, 0, 0, 50%)
  • hsl(0 100% 50% / 50%) -> hsla(0, 100%, 50%, 50%)

Released under the MIT License.