Skip to content

UI library

Great — when building with Astro, your choice of UI libraries changes a bit because Astro is HTML-first, and interactivity must be brought in with frameworks (Svelte, React, Vue…) using islands.

Here is the best way to combine daisyUI + SvelteUI inside an Astro project 👇


🌟 Using daisyUI + SvelteUI in Astro — Is it possible?

Section titled “🌟 Using daisyUI + SvelteUI in Astro — Is it possible?”

Yes — and actually it’s one of the best combos.

Because daisyUI is just a Tailwind plugin, it works perfectly with Astro without any islands or hydration.

✔ Astro handles SvelteUI through Svelte components

Section titled “✔ Astro handles SvelteUI through Svelte components”

You can use:

<SvelteComponent client:load />

or client:idle, client:visible, etc.

So daisyUI builds your design system (global CSS), while SvelteUI handles interactive widgets where needed.


Use daisyUI for:

  • layout
  • buttons
  • forms
  • themes
  • cards
  • navbar
  • hero sections
  • responsive utilities

Astro + Tailwind + daisyUI is very light and extremely fast.


2. Islands for dynamic components → Svelte + SvelteUI

Section titled “✅ 2. Islands for dynamic components → Svelte + SvelteUI”

Put SvelteUI only on components that need interactivity:

  • Modal
  • Toaster / notifications
  • Select dropdown
  • Date picker
  • Carousel
  • Complex forms

Example:

---
import Modal from '../components/Modal.svelte';
---
<Modal client:idle />

This keeps your site:

  • fast
  • lightweight
  • interactive only where needed

daisyUI has strong theme colors. SvelteUI uses tokens like --svelteui-primary, etc.

To unify them, you can override SvelteUI variables with daisyUI values.

Example (global.css):

:root {
--svelteui-primary: var(--p);
--svelteui-text: var(--bc);
}

Now both match visually.


Only hydrate the Svelte components that require JS. This is the Astro advantage.


A more integrated solution for Astro is:

🔥 Skeleton UI (Tailwind components + Svelte components)

Section titled “🔥 Skeleton UI (Tailwind components + Svelte components)”

https://www.skeleton.dev Works better than mixing daisyUI + SvelteUI if you want a unified setup.

But mixing is still totally fine.


🎯 Final Recommendation (For Your Astro Project)

Section titled “🎯 Final Recommendation (For Your Astro Project)”

Astro + Tailwind + daisyUI for styling ➡ Svelte + SvelteUI only for interactive components ➡ Hydrate Svelte on islands (client:idle or client:visible)

This is what most advanced Astro developers use today.


Here is a clear, step-by-step guide to install and use Astro + Tailwind + daisyUI + Svelte + SvelteUI in the same project — the clean and recommended setup.

Everything below is copy-paste ready.


If you don’t already have one:

Terminal window
npm create astro@latest my-app
cd my-app
npm install

Choose the Svelte renderer when asked. (If you didn’t choose it, don’t worry — Step 4 will install it.)


Astro provides an official integration:

Terminal window
npx astro add tailwind

This adds:

  • tailwind.config.mjs
  • postcss.config.cjs
  • and updates astro.config.mjs

Terminal window
npm install daisyui

Then inside tailwind.config.mjs:

import daisyui from 'daisyui';
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./src/**/*.{astro,html,js,jsx,ts,tsx,svelte,vue}",
],
theme: {
extend: {},
},
plugins: [daisyui],
daisyui: {
themes: ["light", "dark"], // optional
},
};

daisyUI is now ready globally.


STEP 4 — Add Svelte support to Astro

Section titled “✅ STEP 4 — Add Svelte support to Astro”

If you didn’t enable Svelte during creation:

Terminal window
npx astro add svelte

This installs:

  • @astrojs/svelte
  • required Vite config

Now you can use .svelte components inside .astro.


Terminal window
npm install @svelteuidev/core @svelteuidev/composables

Then create a global SvelteUI theme provider:

Create file: src/components/SvelteUIProvider.svelte

Section titled “Create file: src/components/SvelteUIProvider.svelte”
<script>
import { SvelteUIProvider } from '@svelteuidev/core';
</script>
<SvelteUIProvider>
<slot />
</SvelteUIProvider>

You will wrap your interactive components with it when needed.


STEP 6 — Use both libraries in an Astro page

Section titled “✅ STEP 6 — Use both libraries in an Astro page”
---
import TestDaisy from '../components/TestDaisy.astro';
import TestSvelte from '../components/TestSvelte.svelte';
import SvelteUIProvider from '../components/SvelteUIProvider.svelte';
---
<html>
<body class="p-10">
<h1 class="text-3xl font-bold text-primary">Astro + daisyUI + SvelteUI</h1>
<!-- daisyUI component -->
<TestDaisy />
<!-- Svelte component (hydrated on demand) -->
<SvelteUIProvider>
<TestSvelte client:load />
</SvelteUIProvider>
</body>
</html>

<button class="btn btn-primary">
DaisyUI Button
</button>

This is pure HTML + CSS classes — no JS needed.


STEP 8 — Create a SvelteUI component

Section titled “✅ STEP 8 — Create a SvelteUI component”
<script>
import { Button } from '@svelteuidev/core';
</script>
<Button>
SvelteUI Button
</Button>

Because it needs interactivity, we hydrate it in the .astro file.


You now have:

All fully compatible.


If you want, I can give you:

✅ a folder structure ✅ a starter GitHub template ✅ a daisyUI + SvelteUI matching theme (so both libraries share colors) ✅ a ready-to-copy layout system

Just tell me!