Skip to content

Preset Legacy Compat

Kolekcja narzędzi kompatybilności wstecznej.

Ten preset nie zawiera żadnych reguł, stosuje postprocess do wygenerowanego CSS z innych presetów.

Domyślnie żadne opcje nie są włączone, musisz jawnie wybrać każdą z nich.

Kod Źródłowy

Instalacja

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

export default defineConfig({
  presets: [
    // ...inne presety
    presetLegacyCompat({
      // opcje
      commaStyleColorFunction: true,
      legacyColorSpace: true
    }),
  ],
})

Options

commaStyleColorFunction

  • Type: boolean
  • Default: false

Convert color functions (rgb() and hsl()) from space-separated to comma-separated, for better compatibility with legacy browsers. Bring back the old behavior before UnoCSS v0.57.0 that was changed to space-separated in #3221 to align with Tailwind CSS.

For examples:

  • 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%)

legacyColorSpace

  • Type: boolean
  • Default: false

Removes color space keywords such as in oklch and in oklab from the generated styles. This is useful for ensuring compatibility with legacy browsers that do not support these modern color spaces.

To enable this feature, set the legacyColorSpace option to true.

Released under the MIT License.