News for hackers. Stuff that matters.
Re:Learn CSS by umut on Friday May 21, 2021 @08:44AM (#27233303)
A viable alternative to all this is using tailwind, can't recommend it highly enough. When you pass the initial period where you feel like you're repeating yourself (1h max) it takes the nervousness out of your CSSing, it feels more like coding and less like schmoozing..

Just a happy user

Re:Learn CSS by ekzy on Friday May 21, 2021 @08:51AM (#27233366)
I like tailwind too but it's not an alternative to learning CSS. You still need to know CSS to be able to use tailwind
Re:Learn CSS by domano on Friday May 21, 2021 @08:55AM (#27233418)
I agree with your first sentence, but not with your second.

For my own homepage i did not write a single line of css.

I am very, very bad with CSS and can't wrap my head around it, but tailwind allowed me to create a very pretty, responsive homepage with very high lighthouse scores (bought tailwind UI too).

Re:Learn CSS by deergomoo on Friday May 21, 2021 @08:59AM (#27233454)
> I am very, very bad with CSS and can't wrap my head around it, but tailwind allowed me to create a very pretty, responsive homepage

Congrats, you now know CSS! It sounds like I'm joking but honestly, Tailwind is essentially composable shorthand for CSS with a design system applied. If you grok Tailwind, you understand the concepts of CSS, you just might not know the full names for all the properties and values.

Re:Learn CSS by domano on Friday May 21, 2021 @09:11AM (#27233556)
Yes, but when i try to apply this knowledge i fail every time.

I do unterstand the basic ideas behind CSS, but is just cant apply it. Tailwind allowed me to apply it.

If i could, i would prefer to write CSS! After 10 years i have given up though.

Re:Learn CSS by dmitriid on Friday May 21, 2021 @09:43AM (#27233898)
That's the thing about Tailwind. It's (almost) the right abstraction.

Personal anecdote, I understood how flexbox works only after using Tailwind for a personal project.

Re:Learn CSS by umut on Friday May 21, 2021 @08:55AM (#27233419)
Yes, very true.. But you just don't need to maintain the exploding specificity hell, instead use a declarative workflow, which is significantly easier to reason about.
Re:Learn CSS by Oddskar on Friday May 21, 2021 @09:00AM (#27233458)
This is like saying an alternative to learning how to cook is to sustain yourself on takeaway.

Tailwind might be nice, but most projects will require in-depth knowledge about CSS.

Re:Learn CSS by nailer on Friday May 21, 2021 @10:40AM (#27234577)
People absolutely do use tailwind as an alternative to understanding CSS. Having seen and worked on projects in tailwind, I feel like that's it's primary purpose.

Go on Twitter and look at the Tailwind community - they see CSS as a doomed, awful language and Tailwind as the thing that makes it pleasant. They're not CSS developers. They're people actively trying to avoid being CSS developers.

Re:Learn CSS by kklisura on Friday May 21, 2021 @08:56AM (#27233422)
Learning any CSS library is not alternative to learning CSS itself.
Re:Learn CSS by MonaroVXR on Saturday May 22, 2021 @11:14AM (#27247311)
It's weird reading ycombinator and the persons above you says something else.
Re:Learn CSS by blacktriangle on Friday May 21, 2021 @10:16AM (#27234215)
I know it's been said before, but no Tailwind does not replace CSS.

Tailwind replaces having to come up with a new semantic class name every time you need to style an element only to realize the actual semantics you picked were completely wrong.

Tailwind is basically a cleaner way to do everything as inline styles.

Re:Learn CSS by Ashanmaril on Friday May 21, 2021 @12:31PM (#27236223)
> Tailwind is basically a cleaner way to do everything as inline styles.

I'd say that's underselling it. For one thing it keeps you within a design system. By default you're given spacing that works in increments of 0.25rem, a handful of colors, etc to work with (which can be replaced/extended) so you have to go out of your way to break the design system that's in place.

Also inline styles don't allow for hover, focus, @media, etc. Which were always a pain in the ass with normal CSS anyway. Using Tailwind was the first time I didn't find writing a responsive UI to be a giant hassle. You just design for mobile and then for anything that needs to change on bigger screens you put a sm: or lg: or whatever breakpoint style and you're done.

Re:Learn CSS by nailer on Friday May 21, 2021 @10:42AM (#27234602)
Tailwind isn't quite inline styles (technical details) but yes, it replaces having to name 'login-box' with a copypasted set of styles that you can't change easily without massive regex work.
Re:Learn CSS by blacktriangle on Friday May 21, 2021 @11:13AM (#27235074)
Until somebody has another similar box so they reuse login-box a bunch in your application, then you realize that they actually need to be customized and have to tear it all apart.

Tailwind doesn't make you copy and paste, it moves the reuse of styles out of CSS which sucks at managing reuse into whatever HTML building system which likely has some concept of reusable views.

Re:Learn CSS by nailer on Friday May 21, 2021 @11:31AM (#27235350)
> Until somebody has another similar box so they reuse login-box a bunch in your application

Then they make `.box` and include it as a mixin. Like CSS developers have done for a decade (and which tailwind itself does using PostCSS)

> Tailwind doesn't make you copy and paste

Yes it does. Moving all styles into individual elements without reuse is copy and paste.

Re:Learn CSS by deergomoo on Friday May 21, 2021 @01:07PM (#27236780)
> Yes it does. Moving all styles into individual elements without reuse is copy and paste

Tailwind all but assumes you will be using something that allows you to extract HTML into components, be that something like React or Vue, or classic partials in a server-side templating language like Twig. You reuse the entire component, rather than just the CSS, which IMO is far better aligned with how apps are actually built.

So no, using Tailwind classes is no more copy pasting than typing CSS in full into a separate stylesheet is copy pasting.

Re:Learn CSS by nailer on Friday May 21, 2021 @05:12PM (#27240033)
You’re misunderstanding the relationship between components and styles.

Login box and messages are separate components, but they share padding metrics, border styles, a palette, etc.

Have you used tailwind before?

Re:Learn CSS by deergomoo on Saturday May 22, 2021 @09:00AM (#27246078)
I use Tailwind almost exclusively these days.

My argument is that using the “mr-1 pl-2” utilities on both a login box and a message would be no more copy pasting than creating a stylesheet with “.login-box { margin-right: 0.25rem; padding-left: 0.5rem; }” and “.message { margin-right: 0.25rem; padding-left: 0.5rem; }”.

And if you’re suggesting that you would create a single CSS class with those properties to apply to both the login box and the message, then it’s my opinion that that is a broken abstraction that falls apart as soon as your designer asks if you can make the spacing in the login box a little looser.

Re:Learn CSS by hu3 on Friday May 21, 2021 @09:28AM (#27233714)
This is like saying that learning JQuery is an alternative to learning JavaScript.
Re:Learn CSS by mkoryak on Friday May 21, 2021 @09:46AM (#27233936)
Except that learning JQuery is an alternative to learning the native javascript DOM API.
Re:Learn CSS by hu3 on Friday May 21, 2021 @10:21AM (#27234303)
DOM API? perhaps

JavaScript? no

Re:Learn CSS by kumarvvr on Friday May 21, 2021 @09:39AM (#27233837)
I really love it, as it provides 1 layer of semantic abstraction over raw css, meaning, it's easier on the mind, very useful for frameworks like React / Angular / Blazor / Vue.

There is a learning curve, but if you assimilate the language, by doing a project or two, you won't have to even look at the documentation for doing your designs.

Re:Learn CSS by yewenjie on Friday May 21, 2021 @08:56AM (#27233424)
I like Tailwind so much. I wonder if there is a checklist of CSS things for common components such as buttons so that I can just follow that and get everything done with Tailwind without thinking much.
Re:Learn CSS by iudqnolq on Friday May 21, 2021 @09:33AM (#27233771)
Tailwind UI is the paid version, Tailwind components the free version (has some gems, but irregular quality and not a consistent design system)
Re:Learn CSS by baxuz on Friday May 21, 2021 @12:30PM (#27236208)
No.
Re:Learn CSS by butt__hugger on Friday May 21, 2021 @09:42AM (#27233886)
Don't use Tailwind, it's garbage.