How do you deal with dynamic classes ?
I found out that using dynamic classes requires you to add the given class to the safe list as Tailwind is only loading classes statically present in the
className
attribute. As this is obviously heavy for maintenance (if you want to keep the size optimised, stripped from unused CSS), how do you deal with this ?
Here is an example, how would you make classes static ?
Solution:Jump to solution
OK, I didn't find this page from the doc which is exactly about the issue:
https://tailwindcss.com/docs/content-configuration...
Content Configuration - Tailwind CSS
Configuring the content sources for your project.
6 Replies
i use something like this
would suggest you dive straight into https://cva.style/docs/getting-started/variants
Variants | cva
Class Variance Authority
And what if you mixes different variants ? Let's say you add to this button an inverted mode ?
Interesting, thank you, is that what you use?
Yea
GitHub
spacedrive/apps/mobile/src/components/primitive/Button.tsx at 03e71...
Spacedrive is an open source cross-platform file explorer, powered by a virtual distributed filesystem written in Rust. - spacedriveapp/spacedrive
Solution
OK, I didn't find this page from the doc which is exactly about the issue:
https://tailwindcss.com/docs/content-configuration
Content Configuration - Tailwind CSS
Configuring the content sources for your project.