News for hackers. Stuff that matters.
Re:Vanilla JavaScript support for Tailwind Plus by tomnipotent on Friday July 25, 2025 @08:52PM (#44690309)
Groups are great. It lets a child element activate an effect on a parent element.

    <div id="parent" class="group"><a class="group/hover:bg-black">Hover</a></div>
This eliminates the need for JS for a wide range of things.
Re:Vanilla JavaScript support for Tailwind Plus by reactordev on Friday July 25, 2025 @09:45PM (#44690573)
But at what cost? If it’s not a CSS builtin, it’s going to use JS - it may not be something you care about, but it will be there. There’s no other way.
Re:Vanilla JavaScript support for Tailwind Plus by lemonberry on Friday July 25, 2025 @10:02PM (#44690657)
I believe it's regular old css. The :has() pseudo class.

https://developer.mozilla.org/en-US/docs/Web/CSS/:has

Re:Vanilla JavaScript support for Tailwind Plus by MrJohz on Saturday July 26, 2025 @12:13AM (#44691260)
It's not even :has, it's just how child selectors in CSS have always worked.

    // Not actually needed, here
    // for competition
    .group {}

    // Child selector
    .group:hover group\/hover\:bg-black {
      background-color: black; 
    }

    // Which is essentially the same as
    .group:hover child {
      background-color: black; 
    }
Re:Vanilla JavaScript support for Tailwind Plus by luckylion on Saturday July 26, 2025 @04:49AM (#44692538)
That doesn't affect the parent (.group) based on the child though.
Re:Vanilla JavaScript support for Tailwind Plus by MrJohz on Saturday July 26, 2025 @05:42AM (#44692753)
No, but `group` doesn't affect the parent in Tailwind. You put `group` in the parent to mark it, and then use the `group/...` syntax to apply different properties to the child, depending on the different states of the parent. This doesn't require `:has`.

I don't think Tailwind has a built-in `:has` tool, but I suspect it would be easy to add one as a custom class.

Re:Vanilla JavaScript support for Tailwind Plus by luckylion on Saturday July 26, 2025 @07:23AM (#44693208)
Oh, I misunderstood the GP then, thanks for clarifying!
Re:Vanilla JavaScript support for Tailwind Plus by omnimus on Saturday July 26, 2025 @09:09AM (#44693819)
Tailwind has few :has tools but it’s imho terrible. They keep inflating the system to nonsense.
Re:Vanilla JavaScript support for Tailwind Plus by reactordev on Saturday July 26, 2025 @02:42PM (#44696147)
This.
Re:Vanilla JavaScript support for Tailwind Plus by omnimus on Saturday July 26, 2025 @05:02AM (#44692586)
Atleast in Tailwind that’s what it should do. You hover over card (.group) and some elements inside change.
Re:Vanilla JavaScript support for Tailwind Plus by omnimus on Saturday July 26, 2025 @04:57AM (#44692563)
Isn’t it funny that in a thread about how Tailwind is bad and people should learn real css… people also think css selectors require JS?
Re:Vanilla JavaScript support for Tailwind Plus by MrJohz on Saturday July 26, 2025 @05:38AM (#44692727)
:has doesn't require JS, I think the previous poster was just confused about which selector `group` is equivalent to.
Re:Vanilla JavaScript support for Tailwind Plus by owebmaster on Saturday July 26, 2025 @07:35AM (#44693270)
Which is a indication they might not know CSS that well.
Re:Vanilla JavaScript support for Tailwind Plus by MrJohz on Saturday July 26, 2025 @08:12AM (#44693508)
Based on other replies, I believe they understood CSS well enough, but didn't understand the exact behaviour of the `group` class in Tailwind. Given neither of your comments seem to have made much sense given the context of the discussion, I wonder if you're just looking for confirmation of things you already 'know'.
Re:Vanilla JavaScript support for Tailwind Plus by reactordev on Saturday July 26, 2025 @02:40PM (#44696125)
I’m sorry but :has is new. 2023. Forgive this grey beard that built the world you know.
Re:Vanilla JavaScript support for Tailwind Plus by owebmaster on Saturday July 26, 2025 @06:06PM (#44697304)
No need to apologize, it just does not make sense to belittle other people's work when you lack the knowledge to judge it. Nobody told you it used JS for the effect, you conjured that up yourself.
Re:Vanilla JavaScript support for Tailwind Plus by Rapzid on Saturday July 26, 2025 @08:38PM (#44698014)
Baseline 2023 meaning all major browsers supported it in their latest versions sometime in 2023.. Like all new CSS stuff it's probably been a very long time coming. Everyone can't pay attention to everything though, regardless of their beard color.
Re:Vanilla JavaScript support for Tailwind Plus by owebmaster on Saturday July 26, 2025 @07:35AM (#44693265)
is it possible to add the hover to the parent without also adding it to the child ?
Re:Vanilla JavaScript support for Tailwind Plus by MrJohz on Saturday July 26, 2025 @08:22AM (#44693587)
What do you mean? It's possible to apply attributes to any element in an arbitrary state: `hover:bg-black` would give an element a black background on hover. It's also apparently possible to apply attributes based on whether a state is fulfilled for a child element (i.e. the :has selector). E.g. `has-[:hover]:bg-black` would give an element a black background if any child is hovered.
Re:Vanilla JavaScript support for Tailwind Plus by owebmaster on Saturday July 26, 2025 @06:17PM (#44697358)
> What do you mean?

the second part of your answer answered it perfectly. Thanks

Re:Vanilla JavaScript support for Tailwind Plus by reactordev on Friday July 25, 2025 @10:55PM (#44690920)
Nice
Re:Vanilla JavaScript support for Tailwind Plus by mcintyre1994 on Saturday July 26, 2025 @01:52AM (#44691700)
Tailwind compiles all the inline stuff to CSS, and this works in plain CSS. It’s just allowing you to define that inline, which you wouldn’t be able to do with inline styles.

It’s the same as how they enable media queries for example, they’re not using JS just plain CSS, but they’re making it available with these inline classes.