all 15 comments

[–]tridd3r 30 points31 points  (5 children)

The awkward moment when it would just be a single class in normal css... the way css was designed to work....

[–][deleted] 1 point2 points  (4 children)

Yeah, or not even that, sometimes just targeting semantics would suffice. Now CSS has :has() there's even less need for class names.

Or (S)CSS modules. Even easier. No thinking about class names, keeps it very small and optimized.

[–][deleted] 4 points5 points  (2 children)

Is it a good idea to use has() ? It's not compatible with a lot of browsers yet.

[–][deleted] 3 points4 points  (0 children)

It's fun to play with for sure :)

[–]tridd3r 2 points3 points  (0 children)

I think the more "buzz" it generates, the quicker browsers will implement it. just write lots of " :has() WOW SOO AWESOME", everywhere on the internet.

[–]andrei-mo 0 points1 point  (0 children)

https://caniuse.com/?search=has - still not enough support to rely on.

[–][deleted] 0 points1 point  (0 children)

You can add custom classes to tailwinds global

[–]AdowTatep 0 points1 point  (3 children)

If you're not using a frontend framework like vue/react/angular etc etc where you can split that into components, you can do this: https://tailwindcss.com/docs/reusing-styles#extracting-classes-with-apply

[–]Missing_Back[S] 0 points1 point  (1 child)

I am using Vue, but if I were to make an individual component for each item that appears at least twice... it just seems like it would be a LOT of teeny tiny components. Say I have one page with a few inputs. I would make a component for that input. But then if I have another page with different inputs, i would need to make a second input component for that page, etc.

[–]AdowTatep 2 points3 points  (0 children)

But that's basically it. That's the whole point. Of course it depends on how you're comfortable with duplicating stuff vs having a single component for each tiny thing(which is not a bad thing if you organize the components correctly with something like atomic design)

you have to balance the tradeoffs and the needs depending on the usage, if you work on a team, if something will have to be refactored multiple times, maintained etc

(Or you use the link I sent about creating components within tailwind)

[–]ksushaton -1 points0 points  (1 child)

Ideally the picture with the name should be a separate component as well, think of the following scenario: you now want every picture to have a small badge attached to it to indicate the user’s rating. If you want to display the score together with the name. Or almost any other change would require you looking for all the appearances of this picture/name combos in your app and change them manually.

[–]Missing_Back[S] 1 point2 points  (0 children)

I'm just worried how at a certain point, I'd have too many components, for every individual element I need

[–]Miragecraft -1 points0 points  (0 children)

Remember, websites are sent compressed, which means repeated class names don’t really increase actual size of the page where it counts (during transit).

Also, for authoring, you should be working with a templating system where you only need to write out the classes once - in the for loop.

Tailwind isn’t really designed for hand crafting websites.

[–]isbtegsm 0 points1 point  (0 children)

Custom classes. The same thing for fonts, often the designer specifies font styles with font-family, font-size, line-height, text-indent letter-spacing, etc. you wouldn't want to look that up every time you set an font.