Live data from Hacker News

Tailwind is a leaky abstraction

jakelazaroff.com

301–310 of 391 posts

Re: Tailwind is a leaky abstraction

#301
post #246

Earlier quoted context omitted.

But now you just have a single-use html+stylesheet, as I wrote. No separation of concern anywhere, and both html and css can only be written by knowing the other part.

Why is the stylesheet single use? The classes can be used anywhere, as they should be. Make components in the CSS and call them by their classname in HTML. You are building generic components here. I don't see the issue with 'separate files', do people not use split view mode in their IDE? edit- this comment in another thread: https://news.ycombinator.com/item?id=33789859

> Why is the stylesheet single use? The classes can be used anywhere, as they should be. Make components in the CSS and call them by their classname in HTML. You are building generic components here.

The problem with reusing CSS comes, when the style you’ve previously created, is almost, but not exactly perfect for the current component. Changing it to better fit you current need risks breaking existing layouts, and so you are left with overriding it. But when you do that, you eventually end up with a lot of override classes just to change one or two things. So, what do you name these classes? If you name them for what they are intended for (ie. “semantically”), you are bound to end up with a lot of differently named classes, that all do the same or nearly the same thing, because it turns out that we commonly want to override the default styling in very similar ways. You end up with dozens of one-rule classes that all just set float to right or display to none. Alternatively, you name these overrides for what they do. This way, whenever you need to float something right, you just add the `float-right` class to the element. You can now eliminate all those redundant semantically names override classes. But if you go back to the classes you started with, it also turns out that those would have been a lot more reusable if they’d contained fewer rules to begin with. This makes sense, because more rules = more specific, and fewer rules means more general. At this point, I’m sure I don’t have to point out to you, that you’re well on your way to reinventing Tailwind.

Re: Tailwind is a leaky abstraction

#302

Earlier quoted context omitted.

”Never use margin if you can, use flex-box and grid with gaps instead. Placing a children node is parent's responsibility.” Good idea, but importantly only applies to flex and grid layout, not paragraph-like blocks of content. It is not a good practice to use flexbox for layout, especially if there are nested flexboxes. It takes a lot of time to recalculate such a layout, which can be seen when resizing a desktop bro…

"Good idea, but importantly only applies to flex and grid layout, not paragraph-like blocks of content." What does this mean? What's the difference between the two?

Layout is made of container blocks, such as main, sidebar, header, footer.

Container blocks contain other container blocks or content blocks, but never both at the same time.

Content blocks are paragraph-like content and may contain blocks (headings, media) and inline content (leading and body text, captions).

Example hierarchy: layout > main content area > hero element > positioned container > content block > heading

Re: Tailwind is a leaky abstraction

#303
post #218

I love CSS, I'm relatively good at it. Didn't enjoy Tailwind until I really did. Working on a frontend project with other people Tailwind is fantastic. Everyone can see and understand what I've done and there's no trying to understand other people's style sheets, or see what they've done or anything else (especially with the VSCode plugin that orders the Tailwind classes properly). Sure, pure CSS does some bits bette…

I imagine you’d have to use underscores for spaces, otherwise you actually have 3 different classes there.

Re: Tailwind is a leaky abstraction

#304
post #218

I love CSS, I'm relatively good at it. Didn't enjoy Tailwind until I really did. Working on a frontend project with other people Tailwind is fantastic. Everyone can see and understand what I've done and there's no trying to understand other people's style sheets, or see what they've done or anything else (especially with the VSCode plugin that orders the Tailwind classes properly). Sure, pure CSS does some bits bette…

I imagine you’d have to use underscores for spaces, otherwise you actually have 3 different classes there.

You're totally right. You got my point though!

Re: Tailwind is a leaky abstraction

#305

Earlier quoted context omitted.

After enough of these, you get annoyed. If they're typical things that you'd expect a library to solve, sure. If they're "I want my element to rotate in 3D" then most developers would think they're just working outside of the scope of the library.

Libraries that have a scope defined implicitly by what accidentally works or doesn’t work can still be very annoying.

_this_

Re: Tailwind is a leaky abstraction

#306
Here we go again, HTML and CSS have failed at being a unified story, and until there's an HTML 6 or some redesign that takes this into account then we'll keep running into frameworks like this that make it easier to do things for most people

Re: Tailwind is a leaky abstraction

#307
post #198
post #119

Earlier quoted context omitted.

Maybe I'm going out of a limb here, but wasn't the whole point of CSS to not have to touch the markup when changing the styling? Not trying to talk Tailwind down, I have just missed a lot of the evolution of web design in the past 15 or so years.

I've never understood the point of separating markup from the design. I've seen CSS Zen Garden and... neat? But I don't get the point in real-world use. I've never had to redesign a UI in a way where I'd only change CSS and not also be moving around markup in the process. And once you're changing both of those things, there's the overhead of cross-referencing and keeping names and hierarchy in sync. At that point I d…

That reminds me the pitch for the first time I discovered css zen garden: "you can redesign your website without changing the HTML!"

I sort of liked it at first. I even added the opportunity for my users to modify the CSS to add new styles, and share these to other members of the community via a configuration page. It was a neat thing but not many people bothered and in the end it made everything more complicated (and I guess I was really scared of vulnerabilities the whole time, what can go wrong with letting your users set the stylesheet.)

Worse, I think this new approach broke the web as it was: an explosion of flash-layout or photoshop--or-fireworks-cut-layout websites. It used to be beautiful. Now the web is just a series of websites styled by CSS. It's sad.

phones (and their screen size + apple killing flash) really killed the beauty of the web IMO. Now everything's an app.

Re: Tailwind is a leaky abstraction

#308

Earlier quoted context omitted.

After enough of these, you get annoyed. If they're typical things that you'd expect a library to solve, sure. If they're "I want my element to rotate in 3D" then most developers would think they're just working outside of the scope of the library.

Libraries that have a scope defined implicitly by what accidentally works or doesn’t work can still be very annoying.

It's not like the `style` object is far away. Nothing about Tailwind prohibits you from using normal classes.

Re: Tailwind is a leaky abstraction

#309
post #308

Earlier quoted context omitted.

Libraries that have a scope defined implicitly by what accidentally works or doesn’t work can still be very annoying.

It's not like the `style` object is far away. Nothing about Tailwind prohibits you from using normal classes.

Yes tailwind let's you reach through and apply some CSS directly. Almost like its an abstraction that exposes, or leaks, that which it attemps to abstract. A "leaky abstraction" if you will.

Re: Tailwind is a leaky abstraction

#310
post #241

Earlier quoted context omitted.

I've looked at tailwind as an individual, but their pay-for-documentation model is absolutely bullshit. And it doesn't seem to be doing anything different from Bootstrap or 99% of the other CSS frameworks out there. Also, it makes me sad to see people so eager to throw away separation of concerns :( Yes everything describing it is on one screen but now your HTML is filled up with hundreds of words of awful classnames…

> Also, it makes me sad to see people so eager to throw away separation of concerns I don’t think it has ever lived up to expectations, HTML+CSS in that way is simply broken. You can’t really write CSS without hard-coding the HTML structure, so you might as well do it in one file.

I fought against this for a long time, but I have to agree. CSS right next to your HTML/Components makes it a lot easier to keep track of.

Maybe it would've been possible to build tooling around using CSS files that created the same benefits, but now we just don't have to any more.

Post reply on HN