跳至內容

舊版相容預設

舊版相容性工具的集合。

此預設不包含任何規則,它會對其他預設產生的 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
uno.config.ts
ts
import presetLegacyCompat from '@unocss/preset-legacy-compat'
import { defineConfig } from 'unocss'

export default defineConfig({
  presets: [
    // ...other presets
    presetLegacyCompat({
      // options
      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%)

依 MIT 授權條款釋出。