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: 17 comments 21 replies
-
You could consider using the <div style="color: var(--color-{{ $color }})"> Or <div style="color: var(--color-{{ $color }}-500)"> Etc |
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.
-
Is it possible to implement something using this as part of the solution? At the moment it seems to only forces the color variables and nothing else. https://tailwindcss.com/docs/theme
|
Beta Was this translation helpful? Give feedback.
-
The removal of safelist is also a big issue for me, we have an in-house WYSIWYG editor based on TipTap and now I have to list all possible classes that the editor could set |
Beta Was this translation helpful? Give feedback.
-
Same here, no safelist support is a bummer ... |
Beta Was this translation helpful? Give feedback.
-
Any update on how to best safelist in v4? |
Beta Was this translation helpful? Give feedback.
-
This is a complete slop solution.. but just paste your config with your safe list into any decent LLM .. ask it to generate all classnames in a single string separated by spaces. copy paste the classes onto a hidden div somewhere in your app. C’est complètement la merde - but it works. whatever. |
Beta Was this translation helpful? Give feedback.
-
That’s great news. I can throw out my slop generated class list.
…On Sun 6 Apr 2025 at 14:28, Falko Joseph ***@***.***> wrote:
neat, taking a look!
—
Reply to this email directly, view it on GitHub
<#15291 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABDHLJONTG4WVLFVDL2WBCL2YEMYBAVCNFSM6AAAAABS6ZFEW2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENZUGA3TCMY>
.
You are receiving this because you commented.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Would be great to have some additional documentation on how to whitelist multiple classes, not just states. For example, this code is from a production codebase currently using v3:
The v4 docs don't appear to have a list of all the built-in number classes for padding, margin, height, etc. The documentation for This might seem like an edge case, but being able to safelist these kinds of classes is a pretty fundamental need when working with page builders like Storyblok. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
You could consider using the
style
attribute like:Or
Etc