Replies: 1 comment
-
Hey! Yep this is expected and covered in the docs: https://tailwindcss.com/docs/content-configuration#dynamic-class-names Tailwind produces a static CSS file at build time so there’s always going to be some limit to the level of dynamism it can support like this. For example if your code hit an API when the user visits the page that returns a random color, there’s no way we can ever account for that because the stylesheet is already compiled into a static asset before anyone visits the page. Your best bets are mapping to a static list and inline styles like you mentioned, those are the recommended tools for this sort of thing and what we do in our own code. |
Beta Was this translation helpful? Give feedback.
-
In my Vue 3 application, using TailwindCSS v3, I primarily style elements by adding TailwindCSS utility classes. However, I’ve encountered an issue where classes that I conditionally add based on specific cases or dynamically computed values are not included in the production CSS build, leading to missing styles in the production environment.
Steps to Reproduce:
Expected Behavior: TailwindCSS should recognize all utility classes that are conditionally or dynamically applied, and include them in the production build.
Notes:
This issue occurs particularly when using computed properties, conditional rendering, or classes based on props.
Beta Was this translation helpful? Give feedback.
All reactions