---
name: daisyui
description: Tailwind CSS component library providing semantic class names for 50+ components with built-in themes, dark mode, and customization for rapid UI development.
user-invocable: false
disable-model-invocation: true
progressive_disclosure:
entry_point:
- summary
- when_to_use
- quick_start
token_estimates:
entry: 75
full: 4200
---
# DaisyUI Component Library
## Summary
DaisyUI is the most popular Tailwind CSS component library providing semantic class names for 50+ components with built-in themes, dark mode, and customization. Framework-agnostic and production-ready.
## When to Use
- Building UI with Tailwind CSS and need pre-styled components
- Want semantic class names (`btn`, `card`) instead of utility-only approach
- Need built-in theming system with 30+ themes and dark mode
- Require consistent design system across React, Vue, Svelte, or vanilla HTML
- Want to prototype quickly with ready-made components
- Need accessible components following semantic HTML patterns
---
## Quick Start
### Installation
```bash
npm install -D daisyui@latest
```
### Configuration
Add to `tailwind.config.js`:
```javascript
module.exports = {
plugins: [require("daisyui")],
daisyui: {
themes: ["light", "dark", "cupcake"], // Enable specific themes
darkTheme: "dark", // Default dark theme
base: true, // Base styles
styled: true, // Component styles
utils: true, // Utility classes
},
}
```
### Basic Usage
```html
Primary Button
Card Title
Card description goes here
Action
Modal Title
Modal content
Close
```
---
## Core Components
### Buttons
```html
Default
Primary
Secondary
Accent
Ghost
Link
Large
Medium
Small
Tiny
Active
Disabled
Loading
C
S
Wide
Block
Outline
```
### Cards
```html
Card Title
Description text
Buy Now
Compact Card
Reduced padding
Overlay Text
Text appears on top of image
```
### Modals
```html
Hello!
Press ESC key or click the button to close
Open Modal
Modal with backdrop
Click outside to close
Responsive
Bottom on mobile, middle on desktop
Close
```
### Forms
```html
Pick one
Option 1
Option 2
Email
Helper text
```
### Navigation
```html
«
Page 1
2
3
»
```
### Layout Components
```html
Hello there
Provident cupiditate voluptatem et in.
Get Started
```
### Data Display
```html
Name
Job
Company
Cy Ganderton
Quality Control Specialist
Littel, Schaden and Vandervort
Hart Hagerty
Desktop Support Technician
Zemlak, Daniel and Leannon
default
primary
secondary
accent
ghost
outline
Total Page Views
89,400
21% more than last month
1984
First Macintosh computer
1998
iMac
70%
```
### Feedback Components
```html
Hover me
Right
```
---
## Theming System
### Built-in Themes
DaisyUI includes 30+ pre-built themes:
```javascript
// tailwind.config.js
module.exports = {
daisyui: {
themes: [
"light", // Default light theme
"dark", // Default dark theme
"cupcake", // Pink/pastel theme
"bumblebee", // Yellow theme
"emerald", // Green theme
"corporate", // Professional blue
"synthwave", // Retro neon
"retro", // Vintage brown
"cyberpunk", // Neon yellow/pink
"valentine", // Pink/red romantic
"halloween", // Orange/purple spooky
"garden", // Green nature
"forest", // Dark green
"aqua", // Blue ocean
"lofi", // Low contrast
"pastel", // Soft colors
"fantasy", // Purple/pink fantasy
"wireframe", // Minimal black/white
"black", // Dark minimal
"luxury", // Gold/black elegant
"dracula", // Purple dark theme
"cmyk", // Print colors
"autumn", // Orange/brown
"business", // Professional dark
"acid", // Neon green
"lemonade", // Yellow/green fresh
"night", // Deep blue dark
"coffee", // Brown coffee shop
"winter", // Blue/white cold
"dim", // Low light dark
"nord", // Nordic blue/gray
"sunset", // Orange/purple gradient
],
},
}
```
### Theme Switching
```html
Light
Dark
Cupcake
Synthwave
```
### Dark Mode
```javascript
// Auto dark mode based on system preference
module.exports = {
daisyui: {
themes: ["light", "dark"],
darkTheme: "dark",
},
}
```
```html
```
### Custom Theme
```javascript
// tailwind.config.js
module.exports = {
daisyui: {
themes: [
{
mytheme: {
"primary": "#a991f7",
"secondary": "#f6d860",
"accent": "#37cdbe",
"neutral": "#3d4451",
"base-100": "#ffffff",
"info": "#3abff8",
"success": "#36d399",
"warning": "#fbbd23",
"error": "#f87272",
},
},
],
},
}
```
### Extending Existing Themes
```javascript
module.exports = {
daisyui: {
themes: [
{
light: {
...require("daisyui/src/theming/themes")["light"],
primary: "#0000ff", // Override primary color
".btn-twitter": { // Custom component
"background-color": "#1da1f2",
"border-color": "#1da1f2",
},
},
},
],
},
}
```
### CSS Variable Customization
```css
/* Override theme variables */
[data-theme="mytheme"] {
--rounded-box: 1rem;
--rounded-btn: 0.5rem;
--rounded-badge: 1.9rem;
--animation-btn: 0.25s;
--animation-input: 0.2s;
--btn-text-case: uppercase;
--btn-focus-scale: 0.95;
--border-btn: 1px;
--tab-border: 1px;
--tab-radius: 0.5rem;
}
```
---
## Color System
### Semantic Colors
DaisyUI uses semantic color names that adapt to themes:
```html
Primary background
Secondary background
Accent background
Neutral background
Base background (main)
Base background (lighter)
Base background (even lighter)
Info background
Success background
Warning background
Error background
Primary text
Text on primary background
Secondary text
Text on secondary background
Accent text
Text on accent background
Neutral text
Text on neutral background
Base text color
Primary border
Secondary border
```
### Color Utilities
```html
Glassmorphism effect
Ghost button
Outlined
```
---
## Framework Integration
### React
```jsx
import React from 'react';
// DaisyUI works with plain HTML classes
function App() {
return (
Card Title
Card description
Action
);
}
// Modal component
function Modal({ children, id }) {
return (
);
}
// Usage
function App() {
return (
<>
document.getElementById('my_modal').showModal()}
className="btn">
Open Modal
Hello!
Modal content
>
);
}
```
### Vue
```vue
Card Title
Card description
Action
```
### Svelte
```svelte
Open Modal
Card Title
Card description
Action
```
---
## Responsive Design
### Responsive Utilities
```html
Responsive size button
Bottom on mobile, centered on desktop
```
### Mobile-First Approach
```html
Desktop only content
Mobile only content
```
---
## Advanced Configuration
### Complete Configuration
```javascript
// tailwind.config.js
module.exports = {
content: ["./src/**/*.{html,js,jsx,ts,tsx}"],
plugins: [require("daisyui")],
daisyui: {
themes: [
"light",
"dark",
{
mytheme: {
primary: "#570df8",
secondary: "#f000b8",
accent: "#37cdbe",
neutral: "#3d4451",
"base-100": "#ffffff",
info: "#3abff8",
success: "#36d399",
warning: "#fbbd23",
error: "#f87272",
},
},
],
darkTheme: "dark",
base: true,
styled: true,
utils: true,
prefix: "",
logs: true,
themeRoot: ":root",
},
}
```
### Configuration Options
- **themes**: Array of theme names or custom theme objects
- **darkTheme**: Which theme to use for dark mode (default: "dark")
- **base**: Apply base styles (default: true)
- **styled**: Apply component styles (default: true)
- **utils**: Apply utility classes (default: true)
- **prefix**: Prefix for all daisyUI classes (default: "")
- **logs**: Show info in terminal during build (default: true)
- **themeRoot**: Root element for theme (default: ":root")
### Disable Base Styles
```javascript
// Only use components, not base styles
module.exports = {
daisyui: {
base: false, // Don't apply base HTML styles
styled: true,
utils: true,
},
}
```
### Class Prefix
```javascript
// Add prefix to avoid conflicts
module.exports = {
daisyui: {
prefix: "daisy-",
},
}
```
```html
Button
```
---
## Best Practices
### Component Organization
```jsx
// Create reusable component library
// components/Button.jsx
export function Button({ variant = 'primary', size = 'md', children, ...props }) {
return (
{children}
);
}
// Usage
Click me
```
### Theme Management
```javascript
// utils/theme.js
export const THEMES = [
'light', 'dark', 'cupcake', 'bumblebee', 'emerald', 'corporate'
];
export function getTheme() {
return localStorage.getItem('theme') || 'light';
}
export function setTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('theme', theme);
}
export function toggleDarkMode() {
const current = getTheme();
const next = current === 'light' ? 'dark' : 'light';
setTheme(next);
}
```
### Accessibility
```html
Email
We'll never share your email
Tab 1
Tab 2
```
### Performance Optimization
```javascript
// Only import themes you use
module.exports = {
daisyui: {
themes: ["light", "dark"], // Only these 2 themes
},
}
// Or use custom themes only
module.exports = {
daisyui: {
themes: [
{
light: { /* custom light */ },
dark: { /* custom dark */ },
},
],
},
}
```
### Combining with Tailwind
```html
Styled button
```
---
## Common Patterns
### Loading States
```jsx
function DataComponent() {
const [loading, setLoading] = useState(true);
if (loading) {
return (
);
}
return Data content
;
}
```
### Form Validation
```jsx
function LoginForm() {
const [errors, setErrors] = useState({});
return (
);
}
```
### Dropdown Menu
```html
```
### Notification Toast
```jsx
function showToast(message, type = 'info') {
const toast = document.createElement('div');
toast.className = 'toast toast-top toast-end';
toast.innerHTML = `
${message}
`;
document.body.appendChild(toast);
setTimeout(() => toast.remove(), 3000);
}
// Usage
showToast('Operation successful!', 'success');
showToast('An error occurred', 'error');
```
---
## Troubleshooting
### Styles Not Applying
```javascript
// Ensure DaisyUI is in Tailwind plugins
module.exports = {
plugins: [require("daisyui")],
}
// Check content paths include your files
module.exports = {
content: [
"./src/**/*.{html,js,jsx,ts,tsx}",
"./pages/**/*.{html,js,jsx,ts,tsx}",
],
}
```
### Theme Not Changing
```html
```
### Modal Not Opening
```javascript
// Use native dialog API
const modal = document.getElementById('my_modal');
modal.showModal(); // Opens modal
modal.close(); // Closes modal
// Or use checkbox for non-dialog implementation
```
### Conflicts with Tailwind
```javascript
// Use prefix to avoid conflicts
module.exports = {
daisyui: {
prefix: "d-",
},
}
```
---
## Resources
- **Official Documentation**: https://daisyui.com
- **GitHub Repository**: https://github.com/saadeghi/daisyui
- **Component Explorer**: https://daisyui.com/components/
- **Theme Generator**: https://daisyui.com/theme-generator/
- **Community Themes**: https://github.com/saadeghi/daisyui/discussions
- **NPM Package**: https://www.npmjs.com/package/daisyui
- **Tailwind CSS Docs**: https://tailwindcss.com
---
## Migration Guide
### From Plain Tailwind
```html
Button
Button
```
### From Bootstrap
```html
Button
Button
```
### Version Updates
```bash
# Check current version
npm list daisyui
# Update to latest
npm install -D daisyui@latest
# Check changelog
# https://github.com/saadeghi/daisyui/releases
```