-
|
Hello, I have a problem with dynamic class names. I try to dynamically generate a set of styles depending on a color selected by a user in a list. Depending on the selected color, I apply some styles. Example : I list 10 blocks of different colors. When a user clicks on one color, I change the background, when he hovers the color, I apply another style. To this purpose, I have read in the official doc that it is recommended to always use complete class names and to map props to static class names. Here is what I did : 1- Utility file containing the complete class names : In utils.js, I have created an object containing a list of colors and styles to apply for each color : 2- In my component, I import the colors object and apply the different style depending on the color selected by the user : 3- When I test my component, I don't see any style applied (no background color, nothing), but in the DOM, I see that the classnames exist (those from the colors object from the utility class) - but the style is not applied. Do you have any clue of what wrong is with that ? Thnaks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Consider checking:
Otherwise, please consider providing a remotely-hosted git repository that reproduces the unexpected behavior. |
Beta Was this translation helpful? Give feedback.
-
|
Code error Direct 2 HR |
Beta Was this translation helpful? Give feedback.
Consider checking:
utils.jsfile is sufficiently covered by thecontentfile globs in the Tailwind globs.utils.jsmap to "real" classes that Tailwind can generate.Otherwise, please consider providing a remotely-hosted git repository that reproduces the unexpected behavior.