Everytime I end up using style attribute beside className because none of the examples below apply styles to my react elements. Could you explain why this happens and how I can solve the issue?
I've read the docs (https://tailwindcss.com/docs/content-configuration#dynamic-class-names), but my use case is: user is choosing a color from color picker, then I change background according to that. I cannot pass "bg-[colorValue]" value to every single color, so I have to concatenate the value with "bg-[" afterwards.Because I cannot map all colors to full classnames.
const red500 = "red-500";
const red600Hex = "#dc2626";
const bgColor = "bg-[" + red600Hex + "]";
const bgColor2 = "bg-[" + "#dc2626" + "]";
function App() {
return (
<>
<h1 className={` bg-${red500} `}>Hello</h1>
<h1 className={` bg-[${red600Hex}] `}>Hello</h1>
<h1 className={` bg-${`[${red600Hex}]`} `}>Hello</h1>
<h1 className={` ${bgColor} `}>Hello</h1>
<h1 className={` ${bgColor2} `}>Hello</h1>
</>
);
}