←back to thread

304 points ulrischa | 1 comments | | HN request time: 0s | source
Show context
gedy ◴[] No.44687045[source]
Tailwind is fine, but I do find it humorous that they discourage wrapping up tw classes into a component class ala Bootstrap, but they wrap html up like this:

    <el-dropdown class="relative inline-block text-left">
      <button class="inline-flex w-full justify-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm ...">
        Options
      </button>
      <el-menu anchor="bottom end" popover class="w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black/5 transition transition-discrete ...">
      ...
      </el-menu>
    </el-dropdown>

Bootstrap:

    <div class="dropdown">
      <button class="btn btn-secondary dropdown-toggle" type="button">
        Dropdown button
      </button>
      <ul class="dropdown-menu">
        ...
      </ul>
    </div>
(I realize you have full control over looks with TW, but Bootstrap and others have utility classes too for the common stuff.)
replies(3): >>44687309 #>>44687426 #>>44690393 #
nettlin ◴[] No.44687309[source]
When using Tailwind you’re likely to use something like React components, so your actual code is more likely to look like:

  <Menu>
    <MenuButton>Dropdown button</MenuItems>
    <MenuItems>…</MenuItems>
  </Menu>
which is even better than what Bootstrap provides since you get type safety for component props (and more opportunities for customization than what Bootstrap allows)
replies(1): >>44687422 #
notpushkin ◴[] No.44687422[source]
Type safety is good, but the class soup inside the components is just abysmal. And honestly, more often than not I see it spilling out of the components and onto the page layouts.

Design tokens are the one Tailwind feature I genuinely like. Everything else – kill it with fire. Just use whatever scoped CSS your stack does (<style> in Svelte/Vue, Emotion in React?).

replies(2): >>44688225 #>>44688824 #
bernawil ◴[] No.44688225[source]
class soup is what tailwind is. It's terrible because is just abbreviations of css attributes which you still need to know because you'll inevitably fiddle around devtools trying things out.

The only "smart" thing about it is leaning strongly on using rem.

how can it spill out onto the page? it's inline css. The (rare) inline selectors target only descendants.

Truth is that it's winning over because it works best with LLMs. Inline soup works better than looking for styling on different files in the context of the project, so here we are.

replies(2): >>44690931 #>>44698915 #
notpushkin ◴[] No.44690931{3}[source]
> how can it spill out onto the page? it's inline css.

Because people are lazy and don’t make a component for everything. And some people are even lazier and don’t make UI components at all. I’ve seen a project where there was a Button component and that’s it. Well, that was vibe coded probably so makes sense.

> Inline soup works better than looking for styling on different files in the context of the project, so here we are.

Only if you have a separate .css. If you do UI components with [insert your favourite CSS-in-JS solution], it stays in the same file. Maybe the proximity to markup within the file is important?

But no, Tailwind has been rising in popularity long before LLMs came along.

replies(1): >>44695607 #
bernawil ◴[] No.44695607{4}[source]
[I'm assuming styled-components was the preferred css-in-js solution until recently]

> If you do UI components with [insert your favourite CSS-in-JS solution], it stays in the same file.

I mean you can but "best practice" all around has been to put them separate and that's reflected in the majority of github repos in the training data of the LLMs.

> Maybe the proximity to markup within the file is important?

that's my assumption, yes. Seems to me LLMs work best when they output the relevant tokens right there with the markup instead of referencing some previous tokens even if relatively close.

styled components was the recommended solution in popular UI libraries like React MUI up until 2023 when chatgpt came out. Tailwind REALLY blew up with LLMs.

replies(1): >>44699206 #
1. notpushkin ◴[] No.44699206{5}[source]
Yeah, I mean, with either Tailwind or styled-components you want to contain them to “UI components” – e.g. <Button> or <Navbar>. You could mix in some logic, and you’re right, looks like many styled-components folks will split it into two files then – but honestly I would just do in one.

Personally, I’m a Svelte fan, and I think they got it right – you just write <style> in your component and that’s it. I think Vue works in a similar way, too.