Introduction
DaisyUI is a Tailwind CSS plugin that provides semantic component classes on top of Tailwind's utility system. Instead of writing long chains of utility classes for every element, you use short class names like btn, card, and modal while retaining full access to Tailwind utilities for customization.
What DaisyUI Does
- Adds 55+ component classes (buttons, cards, modals, tabs, drawers, etc.) to Tailwind CSS
- Provides 35+ built-in color themes that can be switched with a single data attribute
- Keeps markup clean by replacing verbose utility chains with semantic class names
- Supports theme customization through CSS custom properties and Tailwind config
- Works with any framework that uses Tailwind: React, Vue, Svelte, Astro, and plain HTML
Architecture Overview
DaisyUI is implemented as a Tailwind CSS plugin that injects component styles during the build process. Under the hood, each component class compiles down to a set of Tailwind utilities and CSS custom properties. Themes are defined as collections of CSS variable values, making runtime theme switching possible without rebuilding. The plugin adds zero JavaScript — all interactivity relies on CSS-only techniques or your own framework logic.
Self-Hosting & Configuration
- Install DaisyUI as a dev dependency and add it to the plugins array in
tailwind.config.js - Set a default theme with
daisyui: { themes: ["light", "dark", "cupcake"] }in the config - Create custom themes by defining color variables in the DaisyUI theme configuration
- Override individual component styles by combining DaisyUI classes with Tailwind utilities
- Use the
data-themeattribute on any HTML element to scope themes to sections of a page
Key Features
- Reduces markup verbosity by up to 70% compared to raw Tailwind utility classes
- Built-in theme system with 35+ themes and runtime switching via a data attribute
- Zero JavaScript runtime — all styling is CSS-only and framework-agnostic
- Full compatibility with Tailwind utilities for fine-grained overrides
- Small footprint since unused component styles are purged by Tailwind's build process
Comparison with Similar Tools
- Tailwind CSS (raw) — more flexible but produces verbose markup; no prebuilt components
- shadcn/ui — copy-paste React components; tightly coupled to React and Radix UI
- Bootstrap — standalone framework with its own grid and JS; not built on Tailwind
- Flowbite — another Tailwind component library with JavaScript plugins; heavier approach
- Headless UI — unstyled accessible components; requires writing all visual styles yourself
FAQ
Q: Does DaisyUI increase my CSS bundle size? A: Not significantly. Tailwind's purge process removes unused DaisyUI classes in production, so only the components you use end up in the final CSS.
Q: Can I use DaisyUI with Tailwind v4? A: DaisyUI v5 is designed for Tailwind v4. Check the documentation for the latest compatibility matrix.
Q: Does DaisyUI add any JavaScript? A: No. DaisyUI is CSS-only. Interactive behaviors like modal toggles use CSS techniques or require your own JavaScript.
Q: Can I mix DaisyUI classes with Tailwind utilities?
A: Yes. DaisyUI classes and Tailwind utilities work together. You can write btn btn-primary rounded-full px-8 to combine both.