This repository demonstrates a bug where Tailwind CSS's @apply
directive fails to apply styles when used with pseudo-selectors such as :hover
, :focus
, etc.
The @apply
directive, intended for applying pre-defined utility classes, does not correctly handle classes containing pseudo-selectors. This leads to the styles not being applied in the expected pseudo-state.
bug.html
in your browser.The solution involves avoiding the use of @apply
with pseudo-selectors and applying styles directly or using JavaScript to handle the hover effect. The bugSolution.html
file demonstrates a working solution.
This bug highlights the limitations of using @apply
with complex class structures and the importance of carefully considering when and how to use it.