Skip to content

Astro Integration

Die UnoCSS Integration für Astro: @unocss/astro. Überprüfen Sie das Beispiel.

Installation

bash
pnpm add -D unocss
bash
yarn add -D unocss
bash
npm install -D unocss
bash
bun add -D unocss
ts
import { defineConfig } from 'astro/config'
import UnoCSS from 'unocss/astro'

export default defineConfig({
  integrations: [
    UnoCSS(),
  ],
})

Erstellen Sie eine uno.config.ts Datei:

ts
import { defineConfig } from 'unocss'

export default defineConfig({
  // ...UnoCSS Optionen
})

Style Reset

Standardmäßig wird Browser Style Reset nicht injiziert. Um es zu aktivieren, installieren Sie das @unocss/reset Paket:

bash
pnpm add -D @unocss/reset
bash
yarn add -D @unocss/reset
bash
npm install -D @unocss/reset
bash
bun add -D @unocss/reset

Und aktualisieren Sie Ihre astro.config.ts:

ts
import { defineConfig } from 'astro/config'
import UnoCSS from 'unocss/astro'

export default defineConfig({
  integrations: [
    UnoCSS({
      injectReset: true // oder ein Pfad zur Reset-Datei
    }),
  ],
})

Verwendung ohne Presets

Dieses Plugin kommt ohne Standard-Presets.

bash
pnpm add -D @unocss/astro
bash
yarn add -D @unocss/astro
bash
npm install -D @unocss/astro
bash
bun add -D @unocss/astro
ts
import UnoCSS from '@unocss/astro'

export default {
  integrations: [
    UnoCSS(),
  ],
}

Für weitere Details lesen Sie bitte das Vite Plugin.

INFO

Wenn Sie ein Meta-Framework auf Basis von UnoCSS erstellen, sehen Sie diese Datei für ein Beispiel, wie Sie die Standard-Presets binden können.

Hinweise

client:only Komponenten müssen im components Ordner platziert oder zur content Konfiguration von UnoCSS hinzugefügt werden, um verarbeitet zu werden.

Released under the MIT License.