What is daisyui?
DaisyUI is a plugin for Tailwind CSS that provides a set of pre-designed components and utilities to help developers quickly build modern and responsive user interfaces. It extends Tailwind CSS with additional classes and components, making it easier to create consistent and visually appealing designs.
What are daisyui's main functionalities?
Pre-designed Components
DaisyUI offers a variety of pre-designed components such as buttons, cards, modals, and more. These components come with default styles that can be easily customized using Tailwind CSS classes.
<button class="btn btn-primary">Primary Button</button>
Utility Classes
In addition to components, DaisyUI provides utility classes that extend Tailwind CSS. These utilities help in quickly applying common styles like padding, margin, background colors, and more.
<div class="bg-base-200 p-4 rounded-lg">Content goes here</div>
Theming
DaisyUI supports theming, allowing developers to switch between different themes easily. This is useful for creating dark mode or other custom themes for your application.
<html data-theme="dark"><body>...</body></html>
Responsive Design
DaisyUI components are designed to be responsive out of the box. This means they adapt to different screen sizes, making it easier to build mobile-friendly applications.
<div class="card lg:card-side bg-base-100 shadow-xl">...</div>
Other packages similar to daisyui
tailwindcss
Tailwind CSS is a utility-first CSS framework that provides low-level utility classes to build custom designs. While DaisyUI extends Tailwind CSS with pre-designed components, Tailwind CSS itself focuses on providing the building blocks for custom designs.
bootstrap
Bootstrap is a popular CSS framework that provides a set of pre-designed components and a grid system. Unlike DaisyUI, which is a plugin for Tailwind CSS, Bootstrap is a standalone framework with its own set of design principles and utilities.
material-ui
Material-UI is a React component library that implements Google's Material Design. It offers a wide range of pre-designed components and theming capabilities. While DaisyUI is built on top of Tailwind CSS, Material-UI is a standalone library specifically for React applications.
ant-design
Ant Design is a comprehensive design system and React UI library. It provides a wide range of high-quality components and design guidelines. Similar to DaisyUI, it aims to help developers build consistent and visually appealing user interfaces, but it is specifically tailored for React applications.
DaisyUI
🌼 Demo
See all components ↗︎
👩💻 Use
1. Install
You need TailwindCSS 2.0+
↗︎
Install package:
npm i daisyui
Then add plugin and preset to tailwind.config.js
module.exports = {
plugins: [
require('daisyui/styled'),
],
presets: [
require('daisyui/preset')
],
}
Or use a CDN
🎨 styled version
<link rel="stylesheet" href="https://unpkg.com/daisyui@latest/dist/styled.css" />
📐 unstyled version
<link rel="stylesheet" href="https://unpkg.com/daisyui@latest/dist/base.css" />
2. Set up the colors for your design system (optional)
If you want to use your custom colors , you need to define the color values in your css. Colors must be themeable so we're using CSS Variables.
Theming guide and examples ↗︎
🤔 FAQ
Why do I need it?
Utility first ↗︎ is fast and scalable but developing a design system with utility first is messy and hard to manage when your codebase gets larger. So why not use a single .btn
class for all your buttons instead of repeating ~15 utility classes on all your files? This way you can make sure all your components are sharing the same CSS and they respect the same design rules.
How does it work?
DaisyUI provides basic/unstyled component classes that you can use for almost all design systems. You will need different .btn
sizes for every project so you can have a basic style that predefined .xs
, .sm
, .lg
sizes for your .btn
but it has no color or additianal styles.
DaisyUI also has an optional styled
version that is useful if you don't want to fully design your components but you want to use custom colors.
DaisyUI is based on tailwind so you can customize everything with utility classes and purge ↗︎ all unused class names.
What's included?
When you add daisyui/styled
as a Tailwind CSS plugin, it gives you ready-to-use UI component classes to use. Like .btn
, .card
, .alert
, etc...
If you use the unstyled version, it has no color or visual style so you can fully style the components with Tailwind utility classes. If you use styled version, you get something pre-designed (like Bootstrap) but you can still customize it with Tailwind classes.
Concepts
Typography, spacing, layout
You will handle these with Tailwind classes. We suggest using the official Tailwind Typography ↗︎ plugin
Colors and theming
You should ditch Tailwind's default and multi-purpose color set and set your custom set of colors for a DaisyUI project. (Theming guide ↗︎)
Components
(like button, card, etc...) DaisyUI will handle this, so you don't need to use many utility classes to build a button. you just use .btn
What is "preset"
module.exports = {
presets: [
require('daisyui/preset')
],
}
When you add DaisyUI preset it will replaces default tailwind colors with a set of semantic color set that is themeable and can be configed with CSS variables.
daisyui/preset
also adds a few borderRadius
that is used in components. They are also configurable with CSS variables.
Extending and customizing
You can use Tailwind utility classes anywhere. So your button element can look like <a class="px-16 m-5 opacity-50 btn">
You're not forced to use all the components. Unused components will be purged anyway.
If you use the base
style, you can fully design elements using your custom css and add custom classes to existing DaisyUI components.
For example, you can style your button this way:
.btn{
@apply font-normal rounded-full border-4 shadow-md;
}
🎛 List of components
Show
Please share