News for hackers. Stuff that matters.
Re:Tailwind V4 Is Finally Out by aembleton on Thursday January 23, 2025 @04:36AM (#42802381)
> I simply don't see the appeal.

- Not having to name CSS classes

- Easier to read as it's inline with the rest of your HTML

- Standardised way of naming so that everywhere uses the same conventions

- Not having to manage a separate file and remove unused components

- Being able to use media queries, which I couldn't do in a style tag

- No risk of changing a class that is used elsewhere. CSS has global scoping which has its benefits but is risky.

Re:Tailwind V4 Is Finally Out by skeletal88 on Thursday January 23, 2025 @04:56AM (#42802491)
The problem is that with bootstrap I have card, table, etc. With tailwind I have an unreadable alpabet soup when I am not a designer but a developer and am not familiar with tailwind.
Re:Tailwind V4 Is Finally Out by Ralfp on Thursday January 23, 2025 @05:08AM (#42802543)
And then you build on that, and you have card-alert, card-message card-message-small, card-body-alert, card-body-message, card-form, card-login-form together with extra sass variables for them.

And then you ask "why not just have variable for each component, not each component's style?" and this is where tailwind steps in.

Re:Tailwind V4 Is Finally Out by gedy on Thursday January 23, 2025 @05:13AM (#42802572)
I greatly agree with you, but should mention that there is DaisyUI which is a Tailwind plugin that adds these for you. It seems inspired by Bootstrap and others: https://daisyui.com/
Re:Tailwind V4 Is Finally Out by mablopoule on Thursday January 23, 2025 @08:37AM (#42803848)
This is the big one for me. In any big enough or unfamiliar frontend project, my go-to way to explore the codebase is to launch the front-end, and use the inspector to check the elements, and then search-back in the codebase the relevant classes to see what page/component display that, and how does it fetches the data.

If there is only an alphabet soup, I no longer have a simple set of classes I can grep the codebase with to quickly find the relevant components.

Re:Tailwind V4 Is Finally Out by yurishimo on Friday January 24, 2025 @06:36AM (#42812188)
This is just not true. You can absolutely grep the soup (I do it daily). Most UI components share a lot of common baselines but include a specific modification for use in place (often a color or extra spacing). That means most of the time, the entire class string is unique to that element, even if the classes themselves are not. At most, you might have a couple of duplications, but then you should probably be looking at a template level component if the functionality is related.

`mx-4 py-2 rounded-xl shadow bg-green-500` is just as easy to global-search for as `notice--success`

Re:Tailwind V4 Is Finally Out by jitl on Friday January 24, 2025 @07:29AM (#42812474)
Use the component library’s inspector/devtools to identify components. Eg in a React app, look at the React component tree rather than the DOM tree
Re:Tailwind V4 Is Finally Out by agos on Thursday January 23, 2025 @05:28AM (#42802640)
no, a single html attribute containing "relative before:absolute before:top-0 before:h-px before:w-[200vw] before:bg-gray-950/5 dark:before:bg-white/10 before:-left-[100vw] after:absolute after:bottom-0 after:h-px after:w-[200vw] after:bg-gray-950/5 dark:after:bg-white/10 after:-left-[100vw]" is not "easier to read" (example taken at random from the Tailwind homepage)
Re:Tailwind V4 Is Finally Out by oneeyedpigeon on Thursday January 23, 2025 @08:17AM (#42803676)
Just viewing the source of the Tailwind homepage breaks me out in a cold sweat. And then there's:

    > console.log(document.querySelectorAll("body > script").length)
    27
Re:Tailwind V4 Is Finally Out by aembleton on Thursday January 23, 2025 @07:32AM (#42803334)
Easier to figure out what to change without affecting other HTML components, though.
Re:Tailwind V4 Is Finally Out by superq on Thursday January 23, 2025 @11:44AM (#42805560)
Individually applied styles kinda defeats the purpose of cascading style sheets though.

As someone who's quite conversant with regular CSS, I really did like the ease of applying whatever style I wanted right in the code without needing to "worry" about whether this div is a "panel" or a "hero" or whatever, but it really does tend to make a huge mess of my HTML in very short order.

Re:Tailwind V4 Is Finally Out by 8n4vidtmkvmk on Thursday January 23, 2025 @08:39PM (#42809777)
Have y'all not heard of css modules or BEM?
Re:Tailwind V4 Is Finally Out by jitl on Friday January 24, 2025 @07:27AM (#42812464)
pointless make-work compared to inline-styles-like workflow like tailwind, if you have a component framework
Re:Tailwind V4 Is Finally Out by 8n4vidtmkvmk on Saturday January 25, 2025 @02:29PM (#42823991)
You might like Styled Components then, if you're using React anyway. Not sure if there's similar systems for other frameworks. I don't consider it pointless make-work to develop a consistent stylesheet to use throughout your app though.
Re:Tailwind V4 Is Finally Out by jitl on Sunday January 26, 2025 @11:26AM (#42831197)
Styled Components is too low-level (let’s name every div!!!) and comes with a substantial performance cost. Tailwind is a much better option.
Re:Tailwind V4 Is Finally Out by 8n4vidtmkvmk on Sunday January 26, 2025 @01:24PM (#42832419)
> a substantial performance cost

I believe the Babel plugin eliminates most of the performance cost.

The naming is double-edged. Often you want to re-use your styled element, so the fact that it has a name from the get-go makes that really easy. But you're right, sometimes it's annoying to pull bits out that you didn't really want to.

Ultimately I went back to CSS Modules. I just don't understand why I'd want to the appeal of Tailwind.. I'd have to learn a new DSL that ultimately gives me less control.

Re:Tailwind V4 Is Finally Out by presentation on Friday January 24, 2025 @06:28AM (#42812153)
Use PandaCSS, the result is similar but the syntax is a readable object instead of… that
Re:Tailwind V4 Is Finally Out by lawn on Thursday January 23, 2025 @05:12AM (#42802568)
> Easier to read as it's inline with the rest of your HTML

I really don't think a big blob of text with a bunch of unnamed divs is easier to read.

The styles night be easier to find but they're absolutely not easier to read.

Re:Tailwind V4 Is Finally Out by 65 on Thursday January 23, 2025 @10:38AM (#42805021)
Big one: Way smaller CSS bundle size.
Re:Tailwind V4 Is Finally Out by benjiro on Wednesday February 05, 2025 @10:51AM (#42950265)
> - Not having to name CSS classes

Most websites are maybe 20 components and localized pages. Not exactly that hard to name and keep constant. Can not think of names, just ask one of the AIs.

> - Easier to read as it's inline with the rest of your HTML

Only if you do a few styles. The moment you have mobile + desktop + dark/light you start to leave lines half a mile long.

> - Not having to manage a separate file and remove unused components

Counterpoint: Components/templates are still the same hell to manage.

> - Being able to use media queries, which I couldn't do in a style tag

CSS ... literally the bread and butter.

> - No risk of changing a class that is used elsewhere. CSS has global scoping which has its benefits but is risky.

Counterpoint: You will end up with styles that are applied to parts, then copied, forgotten to change, and then have a mix of styles that conflict with each other.

And you do not use global scoped CSS, but localized per page. All you need is local CSS + a single parent id/class and voila. Local scoped will not mess with global. Do not do stupid stuff like button { style style style }. No, make global scoped iButton, so you never run into the issue off having parental styles doing funny things to child styles.

Let me introduce our lord and savvier called Nested CSS + Named CSS tags ... Reusable, standardized, ...

Tailscale is frankly a solution for front end JS frameworks, and less for any server rendered html. Use local CSS for html pages that are really local. No need to make global CSS for price cards that you only use on one page. But if something is used over multiple pages, buttons, ... that is global. Simple, no?

Ironically, i am in the process of actually removing Tailscale everywhere because the recent 3 > 4 upgrade screwed so much up. What stayed good? My actual CSS nexted/tag components that i never.

That is one of the issues with frameworks in general, etc, things between versions can really mean a lot more work vs just having everything "basic".

I feel a lot of issue that people have with CSS are more related to not having a proper understanding about CSS, and ignoring some basics. Like do not style base tags. Use nested + custom naming tags, local css + a local id/css and you have no issue with overlap. Best of all, you gain the ability to make easier reusable components as your CSS are the components, not some JS/... whatever call you need to do to render something. It gets messy fast if your breadcrumbs is a components with items, and you need to change something later on. But if its a basic breadcrumbs{} css, adding feature is just a matter of adding naming.

Trust me, took me years to get out of this mindset (and it helped that CSS evolved a lot but most people do not even realize that CSS today != what they know/grew up with)