Tailwind classes don't work in blade with variables ( bg-{{$color}}-400 )
I had following code in my blade file, $color variable has values like red, cyan, gray etc, which all are colors that exist in Tailwind.
<div class="bg-{{$color}}-400">
Hello world
</div>
However when I run the code, refresh the page, even re-run npm run dev, it didn't give my div the proper background color. Until I did it manually, like I rewrote the code as following :
<div class="bg-red-400">
Hello world
</div>
And it was working, and when I changed it back to the original code (with variable) it kept working with red, but the other colors weren't working. So I had to manually add all the colors in as class names, refresh the page and re-change the code to use the variable as color name and now it's working as expected.
Did I do something wrong? Is this a bug in Blade, or Tailwind? Did I not run npm run dev properly? What should I do to avoid this from happening in the future? Because I spent last 3 hours of my life on this and I don't want to face the same error again.
Apart from re-running npm run dev, I also ran php artisan view:clear and php artisan config:clear as well.
Thanks.
Please or to participate in this conversation.