Safelist in V4 #15291
-
It seems that V4 is not recognizing the colors implemented in the backend (if you are not using the full class name like text-{{ $color }}) . In version 3, I used to safelist them as shown below. How should I handle this in V4? tailwind.config.js in v3: |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 4 replies
-
You could consider using the <div style="color: var(--color-{{ $color }})"> |
Beta Was this translation helpful? Give feedback.
-
I believe regex patterns and/or variants don't work in v4. In v4 I have to list all 12 statically, e.g. The following pattern works in v3 but not in v4:
|
Beta Was this translation helpful? Give feedback.
-
Is there any news on how safelist will work in v4? (not using tailwind.config.js) |
Beta Was this translation helpful? Give feedback.
-
This is completely broken. Of these, only one colour displays on the page when using them dynamically.
|
Beta Was this translation helpful? Give feedback.
-
Am also facing the same issue. Have been relying on classes like |
Beta Was this translation helpful? Give feedback.
-
I don't have a lot of generated colors so ended up creating a <div class="text-green-600"></div>
<div class="text-yellow-600"></div>
<div class="text-red-600"></div> This get's picked up by the Tailwind compiler and works. |
Beta Was this translation helpful? Give feedback.
-
An solution is to enable support of safelist inside app.css , so we move away from JS config and have same behavior as before. Because is just very boring to hardcode those classes in somewhere. |
Beta Was this translation helpful? Give feedback.
-
The whole v4 update is a fascinating rollercoaster of emotions. Half of the things from v3 are missing and I am baffled how could this even be released in this state. Back to v3 boys and girls. |
Beta Was this translation helpful? Give feedback.
You could consider using the
style
attribute like: