DEV Community

Manav Misra
Manav Misra

Posted on

Answer: TailwindCSS classes not able to be chosen with variables with React

I was facing issue when receiving a dynamic color prop that was going to be used as: className={rounded px-4 py-2 text-white bg-${bgColor}-500} in the component.

It was not working properly essentially due to naivety of PurgeCSS.

We have to use a safelist option as per the docs

Top comments (0)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay