Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for My Favorite Tailwind Library | Daisy UI
Anjan Shomodder
Anjan Shomodder

Posted on

     

My Favorite Tailwind Library | Daisy UI

Daisy UI is a beautiful and easy-to-use component library for Tailwind CSS. But It is unlike your typical component library, Material UI, or Mantine UI. Instead of providing a set of components, Daisy UI provides a set of utility classes that you can use to build your components i.ebtn,btn-primary,modal,modal-box etc.

Installation

You need to have Tailwind CSS installed in your project. You can use this with any JavaScript framework or just vanilla HTML. I am using Nextjs.

npminstalldaisyui
Enter fullscreen modeExit fullscreen mode

Then add the plugin to yourtailwind.config.js file.

module.exports={plugins:[require('daisyui')],}
Enter fullscreen modeExit fullscreen mode

You can check the video tutorial on my YouTube channel. Consider subscribing if you like the content.

Usage

For example, you want to use a button component.

  • Other UI framework:
import{Button}from'library'constApp=()=>{return<Button>Clickme</Button>}
Enter fullscreen modeExit fullscreen mode
  • Daisy UI:
constApp=()=>{return<buttonclassName='btn'>Button</button>}
Enter fullscreen modeExit fullscreen mode

Button Preview

Customization

  • You can use the class names to customize the components.
constApp=()=>{return(<buttonclassName="btn">Button</button><buttonclassName="btn btn-neutral">Neutral</button><buttonclassName="btn btn-primary">Primary</button><buttonclassName="btn btn-secondary">Secondary</button><buttonclassName="btn btn-accent">Accent</button><buttonclassName="btn btn-ghost">Ghost</button><buttonclassName="btn btn-link">Link</button>)}
Enter fullscreen modeExit fullscreen mode

Image description

Explanation: In the above example, we have used thebtn-primary, andbtn-secondary classes to customize the button component. You have to check the documentation to see which classes are available for customization.

Themes

There are 32 default themes available for you to use i.e.light,dark,cupcake,nord etc.

All daisy ui themes

Change theme

You can change the theme by adding thedata-theme attribute to the container. It could be theHTML,body, or even a simplediv. You can change the theme of a single component by adding thedata-theme attribute.

<htmldata-theme="nord"><body><buttonclassName="btn">Primary</button><buttonclassName="btn"data-theme="cyberpunk">Primary</button></body></html>
Enter fullscreen modeExit fullscreen mode

Button with different themes

To learn more about Daisy UI, you can check out my video tutorial on YouTube. Thank you so much for Reading. Have a great day.

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
mjac profile image
Mitch Jackson
all of your thoughts are in a simulation
  • Email
  • Location
    Atlanta, GA
  • Work
    Software Engineer
  • Joined

Thanks for posting this. Going to try out daisyui on a new project. Hope it makes dark/light mode support faster to build.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Full stack developer, instructor of Cules Coding and DSA with JS YouTube channel, and blogger.
  • Education
    Self Taught | Youtube | Udemy
  • Work
    Full Stack Developer
  • Joined

More fromAnjan Shomodder

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp