Skip to content

Astro Integratie

De UnoCSS integratie voor Astro: @unocss/astro. Bekijk het voorbeeld.

Installatie

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(),
  ],
})

Maak een uno.config.ts bestand:

ts
import { defineConfig } from 'unocss'

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

Stijl Reset

Standaard zal browser stijl reset niet worden geïnjecteerd. Om het in te schakelen, installeer het @unocss/reset pakket:

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

En importeer het in je main entry:

ts
import '@unocss/reset/tailwind.css'
import 'virtual:uno.css'

Opties

injectReset

Of de reset styles moeten worden geïnjecteerd. Standaard false.

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

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

Dit zal automatisch @unocss/reset/tailwind.css injecteren.

Released under the MIT License.