I am using a package called
react-type-animation
for a typewriter text effect with react and tailwind css. But when I add dynamic class to the TypeAnimation component, it does not work. Here is the code that I have tried:
<TypeAnimation sequence={[
"TEXT1",
2000,
"TEXT2",
2000,
"TEXT3",
2000,
]}
speed={50}
className={`text-${theme}-500`}
wrapper="span"
repeat={Infinity}
/>
But when i use static class like text-red-500, it works fine. Is there any way to use dynamic class to the TypeAnimation component?
As per the documentation:
You could:
Have the entire class in the variable you pass to
classNamelikeUse the
styleattribute for truly dynamic colors, ifthemecan be converted to a valid CSS color value (or you could get the color from Tailwind):safelistthe classes, if you have a limited number of known colors: