This is my Button.jsx file:
import React from 'react'
function Button({ btnColor = "white" }) {
const bgColor = `bg-${btnColor.toLowerCase()}-500`
return (
<button className={`${bgColor}`}>{btnColor}</button>
)
}
export default Button
I tried multiple times to identify my problem. The button color is not changing and is fixed while using variables, but working fine while hardcoded ie. directly passing the value, but the output of bgColor is fine and is a String.
I don't see any reason to not be able to run.
As per the documentation:
You could:
classNamelike:btnColorto Tailwind class names:safelistthe classes, if you have a limited number of known colors: