Skip to content
FLAVIO COPES
flaviocopes.com
2026

Show or hide an element by parent class in Tailwind

By Flavio Copes

Learn a lesser-known Tailwind trick that shows or hides an element based on a parent class, using the group utility with the group-[.is-published] variant.

~~~

Little relatively unknown Tailwind trick using group:

<div class="group is-published">
  <div class="hidden group-[.is-published]:block">
    Show only when parent has class "is-published"
  </div>
</div>
Tagged: CSS · All topics
~~~

Related posts about css: