Replies: 1 comment
-
Apologies for long answer but you asked a general question and there's a lot to talk about here so I'm going to slice it to smaller questions: Utility, Component... What's the difference?There is no "best approach". It's just a different level of abstraction.
As you can see:
So how is daisyUI helping?daisyUI is not a replacement for Tailwind CSS. It's an addition because with Tailwind CSS + daisyUI you can create pages faster and you can still customize the details using utility classes. But how about smaller CSS size?I can confirm using daisyUI increases the CSS file size (about 5% to 15% depending on the project) but of course it lowers the markup size about the same amount. Speed of development?Tailwind CSS is suggesting a utility-first approach to maximize the customizability but that's not the fastest way to develop apps. You can try using Tailwind CSS (with no component library) to create a few websites, after a while you will ask yourself "why should I create the same In my experience if you want to develop faster, you would need a higher level of abstraction so instead of writing 60 utility classes for a button, you can just quickly write But is daisyUI against the utility-first approach?And I should mention that daisyUI or any component library on top of Tailwind CSS is not "against the utility-first approach" A daisyUI project is still utility-first but there are additional components for faster development because we don't want to re-invent the wheel for all the common elements. But we already experienced Bootstrap... are we going full circle?Bootstrap's idea of having class names for elements was not bad at all. The problem with bootstrap was lack of customizability. That's why all Bootstrap websites look like each other and the only way to build something different was to write lots of custom CSS to override the default theme. But is it a big commitment to use daisyUI instead of utility classes?It's not a big commitment. You don't have to use daisyUI for everything. For example you can use 2 or 3 components and keep using Tailwind CSS utility classes for everything else. Unused styles will be purged by Tailwind anyway. I'm not sure yet...If you're not sure if you need daisyUI or not, I would suggest keep using utility classes only for 5~6 projects. That would be the point you will come to the conclusion that you need a faster way. |
Beta Was this translation helpful? Give feedback.
-
I was wondering why would
daisyui
use a base parent class likebtn btn-{color}
etc...not used utility classes directly to the element, even Tailwind says not to use such base classes because the compiled .css file would increase in size.
for example, the
btn
class hasdisplay: flex
and I want to addflex
class to another element thedisplay: flex
property will be added tobtn
andflex
classes instead of only one class and that will result in the compiled .css file to increase in size.also, I asked in the Tailwind discord community everyone said they would use utility classes.
I am working on React component library for internal use, but I am really confused about what to use base parent classes or utility classes, and I spent a long time searching on what is the best approach to follow but I came across the issue of increasing in size of the compiled .css file or conflict with tailwind classes
so I am really curious to understand how
daisyui
solved this issue.Beta Was this translation helpful? Give feedback.
All reactions