Skip to content

Best practices for distributing React component libraries with Tailwind v4 classes via npm packages #18545

Closed Answered by vlorian-de
vlorian-de asked this question in Help
Discussion options

You must be logged in to vote

Suggested answer for others running into similar issues

Thanks to @rozsazoltan’s input, I was able to solve the issue in most consuming apps. The actual problem turned out to be a mismatch in Tailwind versions — some apps still used Tailwind v3 while our component library was built with v4.

Once we upgraded those apps to Tailwind CSS v4 and used the @source directive to explicitly include the library files, the purging issue was resolved. This avoided the need for a “safelist” workaround in most cases.

If you’re running into similar problems with missing styles from a Tailwind-based component library, double-check:
• the Tailwind version in all consuming apps
• and use @source in your mai…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@vlorian-de
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by vlorian-de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants