How Add Class To Child Elements With Tailwindcss

Simple add css to child elements with tailwindcss


Type the following code

A simple dom structure

<div>
  <p class='pl'>hi</p>
</div>

So we want to add a class in parent node, we can use [&.]: grammar

<div class="[&_.pl]:h-10">
  <p class='pl'>hi</p>
</div>

Nice work :)