Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
UPDATE: use the
*:variant (introduced in Tailwind 3.4 and still supported in v4).
It doesn’t happen often, but sometimes I wonder, how do I apply a style to a child element, with Tailwind?
The next time this happens, I’ll have this blog post explain it to me.
You can use this class to apply bg-gray-300 (for example) to all child elements of the current element:
*:bg-gray-300
Like this:
<div class="*:bg-gray-300">....</div>
The old arbitrary selector version also works if you need it:
<div class="[&>*]:bg-gray-300">....</div>