richardR
Denoβ€’2y agoβ€’
11 replies
richard

TailwindCSS: Class-Strings build with variables

Since TailwindCSS does not support classes with variables (like I used before with twind), how would you color 10 elements with a Tailwind class but the color is retrieved from a list?
For example:
dark:bg-${color}-200 but the color is different for every button. I would use much more classes like text-color etc. so it was the easiest to do it with a variable that changes with every element.
Was this page helpful?