Skip to content

Issue with Tailwind CSS v4 Not Applying Styles in Built Component Library React TS + Vite #18758

Closed Answered by wongjn
MrFatra asked this question in Help
Discussion options

You must be logged in to vote

Consider:

  • Removing the @import "tailwindcss"; from src/index.css. Consumer apps should contain this @import statement, not the library, otherwise you may get a double-up of Tailwind CSS rules.
  • Add @source directive(s) that point to its own library files that contain Tailwind class names. By default, Tailwind in a consumer will ignore node_modules when scanning for class names. This is where this library would sit in the file system in the consumer, hence both your problems occur.
  • Ensure src/index.css is shipped as a production file. This is so that consumers can @import this file. You can relocate the production version of this file if you so wish but it should contain the uncompiled CSS…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MrFatra
Comment options

Answer selected by MrFatra
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