276 karma · joined June 27, 2012
https://bsky.app/profile/crswll.dev
What an absolute dream.
https://2ality.com/2015/10/property-traversal-order-es6.html
It'll be really nice for container queries when they're ready. Something like: `wider-than-[500px]:hover:text-red-500` and so on.
Also super nice for `:has` (although ordering is a concern at the moment): `[:has(:invalid)]:bg-red-500`.
In a project where you have to name everything semantically you don't know where the hell the padding is going to be.
It's amazing for long term maintainability and quick prototyping. There is a lot of value in classes that does one thing well.
Been wrinting CSS for 15 years, switched to Tailwind 2 years ago, just for reference.
I use classes strictly for styling. I change these styles by adding and removing class names and classList handles it very well without me needing to read the data attribute, make it an array, manipulate it, join it and update the attribute.
The classList api is still a lot more suited for this than dataset. None of the modifications done through the dataset api would reflect in the DOM and be readable by CSS unless you were to convert the list to a space separated string and explicitly set the attribute. classList handles all of this for you.
The classList API makes modifications to the class property very easily.
You'd be essentially limited to one identifier in attribute selectors. You can't really select from multiple identifiers with a data attribute without doing like:
[data-hover*="foo"]
which would search for "foo" anywhere in the attribute, which could mean incorrect substring matches.Chaining attribute selectors would be rough too:
[data-hover*="foo"][data-hover*="bar"] {}
vs .foo.bar {} .m4, .profile-card, .other-card,
.header, .foo, blah {
margin: 4em;
} class="hover:red" -> .hover\:red:hover { color: red }
class="before:red" -> .before\:red::before { color: red }
class="medium:red" -> @media (min-width: 500px) { .medium\:red { color: red }
The important thing though is it doesn't need to be used for everything. I think it makes a lot of sense for structural stuff. When you dig into like, children of a hovered element I can see it getting a little messy.