daisyUI 5
CSS component library for Tailwind CSS 4. Provides semantic class names for common UI components.
Install
- Requires Tailwind CSS 4. No
tailwind.config.js (deprecated in v4).
- Install:
npm i -D daisyui@latest
- CSS file:
@import "tailwindcss";
@plugin "daisyui";
- CDN alternative:
<link href="https://cdn.jsdelivr.net/npm/daisyui@5" rel="stylesheet" type="text/css" />
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
Usage Rules
- Style elements by combining: component class + part classes + modifier classes
- Customize with Tailwind utility classes when daisyUI classes aren't sufficient (e.g.
btn px-10)
- Use
! suffix on utilities as last resort for specificity (e.g. btn bg-red-500!)
- If a component doesn't exist in daisyUI, build it with Tailwind utilities
- Use Tailwind responsive prefixes for
flex/grid layouts
- Only use daisyUI class names or Tailwind utility classes — no custom CSS
- Use
https://picsum.photos/{w}/{h} for placeholder images
- Don't add custom fonts unless necessary
- Don't add
bg-base-100 text-base-content to body unless necessary
- Follow Refactoring UI best practices for design decisions
Class Name Categories
component: Required component class
part: Child part of a component
style: Sets specific style
behavior: Changes behavior
color: Sets specific color
size: Sets specific size
placement/direction: Sets position/direction
modifier: Modifies component
variant: Conditional prefix (variant:utility-class)
Colors
Semantic Color Names
| Color |
Purpose |
primary / primary-content |
Main brand color / foreground on primary |
secondary / secondary-content |
Secondary brand color / foreground |
accent / accent-content |
Accent brand color / foreground |
neutral / neutral-content |
Non-saturated UI / foreground |
base-100/200/300 / base-content |
Surface colors (light to dark) / foreground |
info / info-content |
Informative messages / foreground |
success / success-content |
Success messages / foreground |
warning / warning-content |
Warning messages / foreground |
error / error-content |
Error messages / foreground |
Color Rules
- Use daisyUI color names in Tailwind utilities:
bg-primary, text-base-content
- Colors change automatically per theme — no
dark: prefix needed
- Avoid Tailwind color names (e.g.
text-gray-800) — they don't adapt to themes
- Use
base-* colors for page majority, primary for important elements
*-content colors must contrast well against their associated colors
Config
@plugin "daisyui"; /* no config */
@plugin "daisyui" {
themes: light --default, dark --prefersdark;
root: ":root";
include: ;
exclude: ;
prefix: ;
logs: true;
}
Config options: themes (enable/set default), root, include/exclude (components), prefix (e.g. daisy-), logs.
Custom Themes
@plugin "daisyui/theme" {
name: "mytheme";
default: true;
prefersdark: false;
color-scheme: light;
--color-base-100: oklch(98% 0.02 240);
--color-base-200: oklch(95% 0.03 240);
--color-base-300: oklch(92% 0.04 240);
--color-base-content: oklch(20% 0.05 240);
--color-primary: oklch(55% 0.3 240);
--color-primary-content: oklch(98% 0.01 240);
--color-secondary: oklch(70% 0.25 200);
--color-secondary-content: oklch(98% 0.01 200);
--color-accent: oklch(65% 0.25 160);
--color-accent-content: oklch(98% 0.01 160);
--color-neutral: oklch(50% 0.05 240);
--color-neutral-content: oklch(98% 0.01 240);
--color-info: oklch(70% 0.2 220);
--color-info-content: oklch(98% 0.01 220);
--color-success: oklch(65% 0.25 140);
--color-success-content: oklch(98% 0.01 140);
--color-warning: oklch(80% 0.25 80);
--color-warning-content: oklch(20% 0.05 80);
--color-error: oklch(65% 0.3 30);
--color-error-content: oklch(98% 0.01 30);
--radius-selector: 1rem;
--radius-field: 0.25rem;
--radius-box: 0.5rem;
--size-selector: 0.25rem;
--size-field: 0.25rem;
--border: 1px;
--depth: 1;
--noise: 0;
}
All CSS variables above are required. Colors can be OKLCH, hex, or other formats.
Creating DaisyUI Components
Follow this workflow when creating or extending React components that wrap daisyUI. See references/creating-components.md for detailed patterns, compound component examples, and test templates.
1. Resolve the components directory
Check AGENTS.md or CLAUDE.md for a DAISY_COMPONENTS_DIR variable. If not found, use src/components/daisy.
2. Ensure foundational files exist
Before creating any component, verify the project has the required infrastructure. If any are missing, create them from the bundled scripts/ templates. See references/creating-components.md for the full bootstrapping checklist and file contents.
Required files:
<DAISY_COMPONENTS_DIR>/daisy-meta.ts — from bundled scripts/daisy-meta.ts
generators/daisy/generate-daisy-safelist.ts — from bundled scripts/generate-daisy-safelist.ts (update the import path to point to daisy-meta.ts)
src/app/styles/daisy.css — must import daisyUI plugin and the generated safelist
package.json script "generate:safelist" — must run the generator
- The
daisy.css file must be imported in the root layout or global CSS entry point
3. Register in daisy-meta.ts
Add the new component's capabilities to COMPONENT_CAPABILITIES in <DAISY_COMPONENTS_DIR>/daisy-meta.ts. Reference the daisyUI docs (see Component Reference below) for which modifiers it supports.
4. Create the component
- Follow patterns in existing
<DAISY_COMPONENTS_DIR>/daisy* files
- Prefer compound components for multi-part daisyUI components (card, modal, dropdown, etc.)
- Each sub-component in a compound component gets its own file
- See references/creating-components.md for compound component structure
5. Generate safelist
npm run generate:safelist
Generates src/app/styles/daisy-safelist.css.
6. Add tests
Use the project's test framework (check package.json for jest/vitest). Default to Jest + React Testing Library. Test: rendering, prop variations (colors, sizes, variants), compound component composition, and accessibility.
7. Extend the safelist generator
If the new component introduces a capability modifier not yet handled in generate-daisy-safelist.ts, update buildClassList() to iterate over it.
Component Reference
Component docs are split by category. Read only the relevant file:
- Layout components: See references/layout.md
drawer, navbar, footer, hero, dock, divider, indicator, join, stack, fab
- Data display: See references/data-display.md
card, list, table, stat, badge, avatar, chat, timeline, countdown, diff, carousel, hover-3d, hover-gallery, text-rotate
- Input components: See references/input.md
button, input, textarea, select, checkbox, radio, toggle, range, rating, file-input, filter, fieldset, label, validator, calendar
- Feedback & overlay: See references/feedback.md
alert, modal, toast, loading, skeleton, progress, radial-progress, status, steps, swap, tab
- Navigation & chrome: See references/navigation.md
accordion, collapse, breadcrumbs, dropdown, tooltip, link, kbd, menu, mask, mockup-browser, mockup-code, mockup-phone, mockup-window, pagination, theme-controller
1---2name: daisyui-53description: DaisyUI 5 component library best practices, patterns, and usage for Tailwind CSS 4. Use when building UI with daisyUI class names, creating daisyUI-based layouts, styling HTML with daisyUI components, creating React wrapper components for daisyUI, or any task involving daisyUI (.html, .jsx, .tsx, .vue, .svelte files). Triggers on: daisyUI components (btn, card, modal, drawer, navbar, etc.), daisyUI color names (primary, secondary, base-100, etc.), daisyUI config (@plugin "daisyui"), daisy-meta.ts, generate-daisy-safelist, compound components wrapping daisyUI, or any UI task in a project using daisyUI/Tailwind CSS 4.4---56# daisyUI 578CSS component library for Tailwind CSS 4. Provides semantic class names for common UI components.910## Install11121. Requires Tailwind CSS 4. No `tailwind.config.js` (deprecated in v4).132. Install: `npm i -D daisyui@latest`143. CSS file:15```css16@import "tailwindcss";17@plugin "daisyui";18```194. CDN alternative:20```html21<link href="https://cdn.jsdelivr.net/npm/daisyui@5" rel="stylesheet" type="text/css" />22<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>23```2425## Usage Rules26271. Style elements by combining: component class + part classes + modifier classes282. Customize with Tailwind utility classes when daisyUI classes aren't sufficient (e.g. `btn px-10`)293. Use `!` suffix on utilities as last resort for specificity (e.g. `btn bg-red-500!`)304. If a component doesn't exist in daisyUI, build it with Tailwind utilities315. Use Tailwind responsive prefixes for `flex`/`grid` layouts326. Only use daisyUI class names or Tailwind utility classes — no custom CSS337. Use `https://picsum.photos/{w}/{h}` for placeholder images348. Don't add custom fonts unless necessary359. Don't add `bg-base-100 text-base-content` to body unless necessary3610. Follow Refactoring UI best practices for design decisions3738## Class Name Categories3940- `component`: Required component class41- `part`: Child part of a component42- `style`: Sets specific style43- `behavior`: Changes behavior44- `color`: Sets specific color45- `size`: Sets specific size46- `placement`/`direction`: Sets position/direction47- `modifier`: Modifies component48- `variant`: Conditional prefix (`variant:utility-class`)4950## Colors5152### Semantic Color Names53| Color | Purpose |54|-------|---------|55| `primary` / `primary-content` | Main brand color / foreground on primary |56| `secondary` / `secondary-content` | Secondary brand color / foreground |57| `accent` / `accent-content` | Accent brand color / foreground |58| `neutral` / `neutral-content` | Non-saturated UI / foreground |59| `base-100/200/300` / `base-content` | Surface colors (light to dark) / foreground |60| `info` / `info-content` | Informative messages / foreground |61| `success` / `success-content` | Success messages / foreground |62| `warning` / `warning-content` | Warning messages / foreground |63| `error` / `error-content` | Error messages / foreground |6465### Color Rules661. Use daisyUI color names in Tailwind utilities: `bg-primary`, `text-base-content`672. Colors change automatically per theme — no `dark:` prefix needed683. Avoid Tailwind color names (e.g. `text-gray-800`) — they don't adapt to themes694. Use `base-*` colors for page majority, `primary` for important elements705. `*-content` colors must contrast well against their associated colors7172## Config7374```css75@plugin "daisyui"; /* no config */7677@plugin "daisyui" {78 themes: light --default, dark --prefersdark;79 root: ":root";80 include: ;81 exclude: ;82 prefix: ;83 logs: true;84}85```8687Config options: `themes` (enable/set default), `root`, `include`/`exclude` (components), `prefix` (e.g. `daisy-`), `logs`.8889## Custom Themes9091```css92@plugin "daisyui/theme" {93 name: "mytheme";94 default: true;95 prefersdark: false;96 color-scheme: light;97 --color-base-100: oklch(98% 0.02 240);98 --color-base-200: oklch(95% 0.03 240);99 --color-base-300: oklch(92% 0.04 240);100 --color-base-content: oklch(20% 0.05 240);101 --color-primary: oklch(55% 0.3 240);102 --color-primary-content: oklch(98% 0.01 240);103 --color-secondary: oklch(70% 0.25 200);104 --color-secondary-content: oklch(98% 0.01 200);105 --color-accent: oklch(65% 0.25 160);106 --color-accent-content: oklch(98% 0.01 160);107 --color-neutral: oklch(50% 0.05 240);108 --color-neutral-content: oklch(98% 0.01 240);109 --color-info: oklch(70% 0.2 220);110 --color-info-content: oklch(98% 0.01 220);111 --color-success: oklch(65% 0.25 140);112 --color-success-content: oklch(98% 0.01 140);113 --color-warning: oklch(80% 0.25 80);114 --color-warning-content: oklch(20% 0.05 80);115 --color-error: oklch(65% 0.3 30);116 --color-error-content: oklch(98% 0.01 30);117 --radius-selector: 1rem;118 --radius-field: 0.25rem;119 --radius-box: 0.5rem;120 --size-selector: 0.25rem;121 --size-field: 0.25rem;122 --border: 1px;123 --depth: 1;124 --noise: 0;125}126```127128All CSS variables above are required. Colors can be OKLCH, hex, or other formats.129130## Creating DaisyUI Components131132Follow this workflow when creating or extending React components that wrap daisyUI. See [references/creating-components.md](references/creating-components.md) for detailed patterns, compound component examples, and test templates.133134### 1. Resolve the components directory135Check `AGENTS.md` or `CLAUDE.md` for a `DAISY_COMPONENTS_DIR` variable. If not found, use `src/components/daisy`.136137### 2. Ensure foundational files exist138Before creating any component, verify the project has the required infrastructure. If any are missing, create them from the bundled `scripts/` templates. See [references/creating-components.md](references/creating-components.md) for the full bootstrapping checklist and file contents.139140Required files:141- `<DAISY_COMPONENTS_DIR>/daisy-meta.ts` — from bundled `scripts/daisy-meta.ts`142- `generators/daisy/generate-daisy-safelist.ts` — from bundled `scripts/generate-daisy-safelist.ts` (update the import path to point to daisy-meta.ts)143- `src/app/styles/daisy.css` — must import daisyUI plugin and the generated safelist144- `package.json` script `"generate:safelist"` — must run the generator145- The `daisy.css` file must be imported in the root layout or global CSS entry point146147### 3. Register in daisy-meta.ts148Add the new component's capabilities to `COMPONENT_CAPABILITIES` in `<DAISY_COMPONENTS_DIR>/daisy-meta.ts`. Reference the daisyUI docs (see Component Reference below) for which modifiers it supports.149150### 4. Create the component151- Follow patterns in existing `<DAISY_COMPONENTS_DIR>/daisy*` files152- Prefer compound components for multi-part daisyUI components (card, modal, dropdown, etc.)153- Each sub-component in a compound component gets its own file154- See [references/creating-components.md](references/creating-components.md) for compound component structure155156### 5. Generate safelist157```bash158npm run generate:safelist159```160Generates `src/app/styles/daisy-safelist.css`.161162### 6. Add tests163Use the project's test framework (check `package.json` for jest/vitest). Default to Jest + React Testing Library. Test: rendering, prop variations (colors, sizes, variants), compound component composition, and accessibility.164165### 7. Extend the safelist generator166If the new component introduces a capability modifier not yet handled in `generate-daisy-safelist.ts`, update `buildClassList()` to iterate over it.167168## Component Reference169170Component docs are split by category. Read only the relevant file:171172- **Layout components**: See [references/layout.md](references/layout.md)173 drawer, navbar, footer, hero, dock, divider, indicator, join, stack, fab174- **Data display**: See [references/data-display.md](references/data-display.md)175 card, list, table, stat, badge, avatar, chat, timeline, countdown, diff, carousel, hover-3d, hover-gallery, text-rotate176- **Input components**: See [references/input.md](references/input.md)177 button, input, textarea, select, checkbox, radio, toggle, range, rating, file-input, filter, fieldset, label, validator, calendar178- **Feedback & overlay**: See [references/feedback.md](references/feedback.md)179 alert, modal, toast, loading, skeleton, progress, radial-progress, status, steps, swap, tab180- **Navigation & chrome**: See [references/navigation.md](references/navigation.md)181 accordion, collapse, breadcrumbs, dropdown, tooltip, link, kbd, menu, mask, mockup-browser, mockup-code, mockup-phone, mockup-window, pagination, theme-controller