daisyUI
repository·master·Indexed 12 days ago
https://github.com/saadeghi/daisyuiAn open-source component library for Tailwind CSS that provides a collection of reusable UI components with semantic class names. It functions as a Tailwind CSS plugin and includes a wide array of built-in themes, CSS variables for design tokens, and components such as Dropdowns, Stats, Megamenus, Aura, and Drawers.
What's inside daisyUI
- daisyUI is a popular, free, and open-source component library built for Tailwind CSS. It provides a set of ready-to-use UI components that leverage Tailwind's utility classes, allowing developers to build complex interfaces quickly without writing extensive custom CSS. It is designed to work as a plugin for Tailwind CSS.
What is daisyUI and how does it work?
masterdaisyUI is a collection of semantic CSS class names that act as a high-level abstraction of Tailwind CSS utility classes. It is not a replacement for Tailwind CSS, but a plugin that extends it.
Core Workflow
- Install daisyUI as a dev dependency in your project.
- Add it to your Tailwind CSS configuration as a plugin.
- Use daisyUI class names (like
card,btn, ortoggle) directly in your HTML/components. These classes provide the base styling for UI components, while Tailwind utility classes can be used alongside them for fine-grained customization (spacing, layout, etc.).
Key Concepts
- Utility-first, not utility-only: You use daisyUI for speed and readability, and Tailwind utilities for customization.
- Atomic Design Alignment: Tailwind utility classes act as "atoms" (low-level rules), while daisyUI classes act as "molecules" and "organisms" (higher-level UI components).
- Framework Agnostic: Since it is based on CSS classes, it can be used with any UI framework (React, Vue, Svelte, etc.) or even standalone.
// Conceptual workflow: // 1. npm install -D daisyui // 2. Add to tailwind.config.js: // tailwind.config.js = { // plugins: [require("daisyui")] // } // 3. Use in HTML: // <button class="btn btn-primary">Click me</button>New components in daisyUI 5
masterdaisyUI 5 introduces several new components for building interfaces:
- List: A vertical layout component for displaying information in rows (e.g., products, articles).
- Status: Small icons to visually indicate states like
online,offline, orerror. Available in 5 sizes:xs,sm,md,lg, andxl. - Fieldset: A container for grouping related form elements, including a
fieldset-legendfor titles and alabelfor descriptions. - Label: Provides names or titles for input fields. Supports
floating-labelwhich floats above the field when focused. Can be placed before or after the field. - Filter: A group of radio buttons where selecting one hides others and provides a reset button.
- Calendar: Provides styles compatible with popular libraries: Cally (web component), Pikaday (JS), and React Day Picker.
- Validator: Automatically changes form element colors to
errororsuccessbased on validation rules and can display hint text. - Dock: A redesigned replacement for
bottom-navigation. A horizontal bar that sticks to the bottom of the screen. Available in 5 sizes:xs,sm,md,lg, andxl. It is compatible withsafe-area-inset-bottomon mobile devices.
Major component improvements in daisyUI 5
masterMany existing components received significant updates in version 5, including new modifiers, features, and accessibility improvements:
- Alert: New soft/dash styles, vertical/horizontal layout options.
- Badge: New soft/dash styles.
- Button: New hover behavior for
ghost/outlinestyles, new soft/dash styles. - Card: New radio card functionality, new dash variant.
- Checkbox/Radio: New design and accessibility improvements.
- Dropdown: Now supports Popover API and Anchor Positioning; includes
dropdown-centermodifier; clicking the button toggles the dropdown if open. - Modal: New positioning options:
modal-start,modal-end, andmodal-top. - Stack: Now uses CSS grid layout with new directional options.
- Steps: Ability to add custom icons.
- Tab: New
tabs-borderstyle and top/bottom positioning. - Toggle: New custom icons support.
- Tooltip: New
tooltip-contentclass.
Card Component Overview
masterThe Card component is used to group and display content in a readable way. A standard card structure typically includes a
figure(for images), acard-body(for content), and optionallycard-actions(for buttons or interactive elements).<div class="card w-96 bg-base-100 shadow-sm"> <figure><img src="https://img.daisyui.com/images/stock/photo-1606107557195-0e29a4b5b4aa.webp" alt="Shoes" /></figure> <div class="card-body"> <h2 class="card-title">Card Title</h2> <p>A card component has a figure, a body part, and inside body there are title and actions parts</p> <div class="justify-end card-actions"> <button class="btn btn-primary">Buy Now</button> </div> </div> </div>What to expect from daisyUI 5
masterdaisyUI 5 is a major update designed to be fully compatible with Tailwind CSS 4 and modern browser features. Key shifts include moving from a JS-based configuration to a pure CSS architecture, leveraging native CSS features like nesting, container queries, and the Popover API to reduce bundle size and complexity.Core improvements in daisyUI 5
masterdaisyUI 5 introduces several significant architectural improvements:
- Tailwind CSS 4 Compatibility: Supports the new
@pluginsyntax. - Zero Dependencies: The package has been stripped of all dependencies, leading to faster builds and a cleaner
node_modules. - Reduced Size: The NPM package is 61% smaller, and the CDN file (including all components and colors) is 75% smaller (approx. 34 kB compressed).
- Improved Color Variables: Uses standard CSS color formats (like
oklch) instead of complex numeric extractions. This makes variables more readable and allows for easy customization via browser developer tools.
- Tailwind CSS 4 Compatibility: Supports the new
Collapse Component Overview
masterThe
collapsecomponent is used for showing and hiding content. It can be implemented using several different interaction models depending on your needs (focus-based, checkbox-based, or native HTML elements).Core Classes:
collapse: The main container.collapse-title: The part of the component that acts as the trigger/header.collapse-content: The part containing the hidden content.
Modifiers:
collapse-arrow: Adds an arrow icon.collapse-plus: Adds a plus/minus icon.collapse-open: Forces the collapse to be open.collapse-close: Forces the collapse to be closed.
What daisyUI provides
masterdaisyUI adds a component layer to your Tailwind CSS setup. Key features include:
- Component Families: Includes 61 component families.
- Themes: Ships with 35 built-in themes for easy color token management.
- Framework Agnostic: daisyUI does not ship React, Vue, or Svelte components. It only provides CSS classes, meaning your chosen framework retains full control over component state and behavior.
- Installation Methods:
- For modern projects (v5+): Install via
@plugin "daisyui". - For quick HTML prototypes: Use via CDN with
@tailwindcss/browser@4.
- For modern projects (v5+): Install via
What is daisyUI?
masterdaisyUI is a component library built on top of Tailwind CSS. While Tailwind CSS provides utility classes for individual CSS rules, daisyUI provides semantic component class names (like
btn) to speed up development.It follows a utility-first (not utility-only) philosophy: you use component classes for speed and utility classes for customization. This allows you to combine the rapid development of a component library with the extreme flexibility of Tailwind CSS.
Overview of Nexus custom style files
masterNexus uses a structured folder
/styles/custom/for overrides and extensions:layout.css: Styles for the topbar, sidebar, and rightbar.animation.css: Animation keyframes and utilities.components.css: Minor overrides to daisyUI components (can be removed if not needed).plugins.css: Plugin overrides to ensure compatibility between Nexus and daisyUI styles.iconify.js: Plugin for Iconify to allow adding additional icon sets.
What is Mary UI?
masterMary UI is a collection of Laravel Blade components designed for Livewire 3. It is built on top of daisyUI and Tailwind CSS. It does not ship custom CSS; instead, it relies on daisyUI and Tailwind for styling, allowing developers to customize component styles by overriding daisyUI and Tailwind CSS classes inline.