-
-
Couldn't load subscription status.
- Fork 4.8k
Description
What version of Tailwind CSS are you using?
v4.1.7
What's the issue?
In elixir, a list of strings can be generated by writing e.g. ~W(bg-red-500 text-blue-500). This is equivalent to writing ["bg-red-500", "text-blue-500"]. An example of this behavior to define a list of predefined classes to go into HTML components can be seen here. Had those lines been written using the ["bg-red-500", "text-blue-500"] or even ~W( bg-red-500 text-blue-500 ), the tailwind tool would've picked up the styles correctly. The first style (~W(bg-red-500 text-blue-500)) also used to work correctly with Tailwind 3, but after upgrading to Tailwind 4, it doesn't seem to work anymore.
In short, after upgrading to Tailwind 4, it seems like the tokenizer that searches for tailwind classes includes parenthesis as part of a token, meaning that writing ~W(bg-red-500 text-blue-500) in my source code means that Tailwind will no longer pick up those classes. This behavior has changed from Tailwind 3.
Was this change on purpose? I don't see any mention in the release notes or upgrade-guide about the tokenization-process changing, but perhaps I'm missing something.
See also these issues: maxmarcon/live_select#118, phoenixframework/phoenix#6331