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.
✔ Astro handles daisyUI natively
Section titled “✔ Astro handles daisyUI natively”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.
🔥 Recommended Architecture
Section titled “🔥 Recommended Architecture”✅ 1. Base UI → Tailwind + daisyUI
Section titled “✅ 1. Base UI → Tailwind + daisyUI”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
⚠️ Things to keep in mind
Section titled “⚠️ Things to keep in mind”1️⃣ Design consistency
Section titled “1️⃣ Design consistency”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.
2️⃣ Don’t hydrate the whole page
Section titled “2️⃣ Don’t hydrate the whole page”Only hydrate the Svelte components that require JS. This is the Astro advantage.
3️⃣ If you need a full UI system
Section titled “3️⃣ If you need a full UI system”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)”⭐ Best combo (flexible, easy, fast):
Section titled “⭐ Best combo (flexible, easy, fast):”➡ 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.
✅ a step-by-step config guide
Section titled “✅ a step-by-step config guide”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.
✅ STEP 1 — Create an Astro project
Section titled “✅ STEP 1 — Create an Astro project”If you don’t already have one:
npm create astro@latest my-appcd my-appnpm installChoose the Svelte renderer when asked. (If you didn’t choose it, don’t worry — Step 4 will install it.)
✅ STEP 2 — Install Tailwind CSS
Section titled “✅ STEP 2 — Install Tailwind CSS”Astro provides an official integration:
npx astro add tailwindThis adds:
tailwind.config.mjspostcss.config.cjs- and updates
astro.config.mjs
✅ STEP 3 — Install daisyUI
Section titled “✅ STEP 3 — Install daisyUI”npm install daisyuiThen 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:
npx astro add svelteThis installs:
@astrojs/svelte- required Vite config
Now you can use .svelte components inside .astro.
✅ STEP 5 — Install SvelteUI
Section titled “✅ STEP 5 — Install SvelteUI”npm install @svelteuidev/core @svelteuidev/composablesThen 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”Example Astro page: src/pages/index.astro
Section titled “Example Astro page: src/pages/index.astro”---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>✅ STEP 7 — Create daisyUI component
Section titled “✅ STEP 7 — Create daisyUI component”src/components/TestDaisy.astro
Section titled “src/components/TestDaisy.astro”<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”src/components/TestSvelte.svelte
Section titled “src/components/TestSvelte.svelte”<script> import { Button } from '@svelteuidev/core';</script>
<Button> SvelteUI Button</Button>Because it needs interactivity, we hydrate it in the .astro file.
🎉 DONE!
Section titled “🎉 DONE!”You now have:
⭐ Astro
Section titled “⭐ Astro”⭐ Tailwind
Section titled “⭐ Tailwind”⭐ daisyUI (global styles/components)
Section titled “⭐ daisyUI (global styles/components)”⭐ Svelte islands
Section titled “⭐ Svelte islands”⭐ SvelteUI interactive components
Section titled “⭐ SvelteUI interactive components”All fully compatible.
🧪 Optional Improvements
Section titled “🧪 Optional Improvements”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!