Tailwind: Apply custom CSS to variant
12 February 2026 (Updated 12 February 2026)
In addition to applying utility classes to variants via HTML like with the hover:text-blue-600 variant here:
<div class="hover:text-blue-600">Hello there</div>
You can also apply styles based on a variant inside CSS:
@layer components {
.btn {
@variant hover {
@apply text-green-600;
}
}
}
Tagged:
Tailwind recipes