daisyUI

repository·master·Indexed 12 days ago

https://github.com/saadeghi/daisyui

An 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.

Tokens
243.9K
Snippets
904
Records
1.1K
Agent score
98%

What's inside daisyUI

  1. Overview of daisyUI

    master
    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.
  2. What is daisyUI and how does it work?

    master

    daisyUI 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

    1. Install daisyUI as a dev dependency in your project.
    2. Add it to your Tailwind CSS configuration as a plugin.
    3. Use daisyUI class names (like card, btn, or toggle) 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>
  3. New components in daisyUI 5

    master

    daisyUI 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, or error. Available in 5 sizes: xs, sm, md, lg, and xl.
    • Fieldset: A container for grouping related form elements, including a fieldset-legend for titles and a label for descriptions.
    • Label: Provides names or titles for input fields. Supports floating-label which 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 error or success based 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, and xl. It is compatible with safe-area-inset-bottom on mobile devices.
  4. Major component improvements in daisyUI 5

    master

    Many 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/outline styles, 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-center modifier; clicking the button toggles the dropdown if open.
    • Modal: New positioning options: modal-start, modal-end, and modal-top.
    • Stack: Now uses CSS grid layout with new directional options.
    • Steps: Ability to add custom icons.
    • Tab: New tabs-border style and top/bottom positioning.
    • Toggle: New custom icons support.
    • Tooltip: New tooltip-content class.
  5. Card Component Overview

    master

    The Card component is used to group and display content in a readable way. A standard card structure typically includes a figure (for images), a card-body (for content), and optionally card-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>
  6. Core improvements in daisyUI 5

    master

    daisyUI 5 introduces several significant architectural improvements:

    • Tailwind CSS 4 Compatibility: Supports the new @plugin syntax.
    • 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.
  7. Collapse Component Overview

    master

    The collapse component 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.
  8. What daisyUI provides

    master

    daisyUI 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.
  9. What is daisyUI?

    master

    daisyUI 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.

  10. Overview of Nexus custom style files

    master

    Nexus 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.