TailwindCSS @apply - the right approach?
Paweł Ludwiczak
Posted on March 10, 2021
I've been experimenting with Tailwind quite a lot recently and there's one thing that I can't figure out... Which of these is better:
.element {
@apply bg-red ... hover:bg-green ... focus:bg-yellow ...;
}
or...
.element {
@apply bg-red ...;
&:hover {
@apply bg-green ...;
}
&:focus {
@apply bg-yellow ...;
}
}
The latter example is probably more readable but on the other hand it doesn't utilize Tailwind's variants. So I'm wondering if there's any difference between one and the other? Maybe performance?
💖 💪 🙅 🚩
Paweł Ludwiczak
Posted on March 10, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
watercooler Why does a reboot make your PC run SO much faster than running all the cleaning tools you can possibly imagine?
November 30, 2024