Live data from Hacker News

DaisyUI – Tailwind CSS Components

daisyui.com

151–160 of 174 posts

Re: DaisyUI – Tailwind CSS Components

#151

We've gone full circle - CSS components to inline CSS-in-HTML back to CSS components. But I actually think I will use this. A big problem with CSS is that you end up making overrides no matter how composable you make the classes. And some simple things (e.g. responsiveness) are unintuitive and / or annoying to do in CSS. Hence Tailwind's "CSS-in-HTML" mini classes. But that doesn't fill the core purpose of CSS, bigge…

Interesting. I write CSS with absolutely no overrides. I compose at the JSX component level, so there's one Button component used everywhere, not a btn class that gets applied to random components. I usually need to reuse more than just a style, so why not encapsulate it at the component level? If I _do_ want to compose individual styles, I use Sass mixins.

And I find that looking at a single media query over semantic classes to be far easier to understand than utility classes scattered over multiple elements. Looking at tailwind responsive classes hurts my brain.

Re: DaisyUI – Tailwind CSS Components

#152

I am new to UI/UX. Is it comparable to bootstrap? How is it actually different from the CSS and UI component libraries?

You could say it's a component library like Bootstrap but it's customizable in core because it's based on Tailwind CSS. For example if you want to customize a Bootstrap button, you need to write additional CSS files. With daisyUI you can simply add a class name.

Is it similar to reactstrap or react bootstrap?

Re: DaisyUI – Tailwind CSS Components

#153

Very welcome. Sometimes the amount of classes needed in Tailwind is enormous. I paid for the TailwindUI pack too. But as nice as Tailwind is, the guys who built TailwindUI don't really get or understand a lot of real-world design patterns. A lot of stuff in there is needlessly complicated. Our team end up trimming down things to 50% of the markup that they use, while retaining full responsiveness. Overuse of flex for…

Exactly. I paid for TailwindUI too but have been disappointed by the execution in code. I love the visual design, but give me some abstractions and not 20 classes per element.

TUI design + DaisyUI's abstractions is the dream.

Re: DaisyUI – Tailwind CSS Components

#154

Earlier quoted context omitted.

I've never used Tailwind, but am familiar with Bootstrap. When looking at the examples, the ones on the right looked pretty much exactly like Bootstrap and I didn't understand what was interesting or novel about it. Is the code on the left (with lots of classes) actually what tailwind is like to use in practice?

> Is the code on the left (with lots of classes) actually what tailwind is like to use in practice? As a fan of tailwind, I can say that I initially thought this was dumb and it would be hard to read through a huge number of classes applied to each HTML element. Later, I found that for many of my reusable components, I could combine classes into a single class. As an example, my stylesheet may look like this: @tailwi…

Couldn't you just write a normal CSS class though, instead of going through the rigmarole of Tailwind?

Re: DaisyUI – Tailwind CSS Components

#155

Earlier quoted context omitted.

Absolutes are the problem. DaisyUI gives the flexibility of using Tailwind directly or higher level classes. Tailwind is great but sometimes you end up having 10-15+ classes for basic components that makes the code harder to read and reason with. We should have utility classes and composability, but relying on them exclusively is also not necessarily the best way either.

Can't you just use @apply to make a single uniform style that utilizes all those classes? That's my understanding at least, like if you want to make a button, instead of have the same 10+ classes posted everywhere you make a new class with @apply and keep the styles uniform. Then in the future if you need to change one of the core utilities it's also easily updated to all you the @apply classes you make. Am I misunde…

Tailwind is supposed to be used with components. Often it's React/Vue/Web components, but CSS components with @apply, like you're doing, also work perfectly fine.

Re: DaisyUI – Tailwind CSS Components

#156
post #37

I’m not saying this is ugly but the visual execution of some of these components is poor. No good usage of padding in some examples, poor ratios between the typography and the containers, inconsistent use of different line widths and border radius, weird and incosistent design choices in spacing and proportions… I mean. This looks alright and it will certainly make any UI look pretty decent, but the execution is not…

Back when Bootstrap 2 was the most popular UI library one of the biggest problems with it was that the defaults were good enough that no one changed them, and consequently every SaaS startup's product looked the same for about 5 years. Pushing people to tweak things while still giving them a solid foundation is a good thing. I'm not saying that's necessarily the case here, but there is a strong argument in favor of n…

I take it you dislike native software then...

Re: DaisyUI – Tailwind CSS Components

#157
post #37

Earlier quoted context omitted.

Back when Bootstrap 2 was the most popular UI library one of the biggest problems with it was that the defaults were good enough that no one changed them, and consequently every SaaS startup's product looked the same for about 5 years. Pushing people to tweak things while still giving them a solid foundation is a good thing. I'm not saying that's necessarily the case here, but there is a strong argument in favor of n…

I take it you dislike native software then...

I'd do 100% of my job in a browser if I had the option.

Re: DaisyUI – Tailwind CSS Components

#158
Is there something exactly like this that doesn't depend on tailwind?

Using bootstrap themes are what I do now but they always have a limited number of components and don't have ready to go, copy-pastable documentation.

Ideally I'd have a library that I can just copy paste beautiful pre-made components.

Re: DaisyUI – Tailwind CSS Components

#159
post #143

Earlier quoted context omitted.

> Is the code on the left (with lots of classes) actually what tailwind is like to use in practice? As a fan of tailwind, I can say that I initially thought this was dumb and it would be hard to read through a huge number of classes applied to each HTML element. Later, I found that for many of my reusable components, I could combine classes into a single class. As an example, my stylesheet may look like this: @tailwi…

But why would you use @apply instead of something like: .button { background-color: $gray-100; border: 1px $gray-200 /\* so on... \*/ } i don't understand how these "micro" css classes actually help versus just setting the property.

After working with Tailwind for a period of time I came to the exact same conclusion. You can achieve all of this in a better way using CSS variables. You can transform this:

    @tailwind base;
    @tailwind components;
    @tailwind utilities;

    @layer components {
     .button {
       @apply text-2xl p-2 bg-gray-100 text-gray-600 border border-gray-200 cursor-pointer hover:bg-gray-200 hover:border-gray-300;
     }
    }
in to this:

    .button {
      font-size: var(--text-2xl);
      padding: var(--p-2);
      background-color: var(--gray-100);
      color: var(--gray-600);
      border: solid 1px var(--gray-200);
      pointer: cursor;
    }
    .button:hover {
      background-color: var(--gray-200);
      border-color: var(--gray-300);
    }
Adjust variable names to taste. No build step, no extra tooling, just as readable in my opinion. On top of that, using CSS variables means that those values can be changed at runtime. You basically get user-driven theming for free.

I'm building an app like this right now and it's been lovely.

Re: DaisyUI – Tailwind CSS Components

#160
post #143

Earlier quoted context omitted.

> Is the code on the left (with lots of classes) actually what tailwind is like to use in practice? As a fan of tailwind, I can say that I initially thought this was dumb and it would be hard to read through a huge number of classes applied to each HTML element. Later, I found that for many of my reusable components, I could combine classes into a single class. As an example, my stylesheet may look like this: @tailwi…

But why would you use @apply instead of something like: .button { background-color: $gray-100; border: 1px $gray-200 /\* so on... \*/ } i don't understand how these "micro" css classes actually help versus just setting the property.

It's a straitjacket to reduce inconsistency across different sections of a large app/family of apps - and which help a bit with finding common styles for refactoring.

It's not so much about what you do as a single designer on the initial design, more about what a team of designers do when adding new apos/modules to an existing product.

In theory you could use bootstrap and a theme - but your fellow team members will get lost, re-invent some styles etc.

I'm inclined to solve this problem with discipline and corporal punishment - but I'm afraid the tailwind-people are on to something.

Basically the cascading part of css does not work well for applications / a suite of applications - it works better for actual hypertext documents (like sgml might) - where you can make a layout that works, while the browser handles the user experience (UX). When layout/design becomes "just" part of how an app looks, but the important is how it beheaves (including things like hover, expanding menus etc) - bare CSS doesn't work as well. Not technically, but from a perspective of an evolving code base.

Post reply on HN