Tailwind classes from library components not applied in consuming app #19398
-
|
I have a shared component library built with Shadcn UI + Tailwind v4+ TypeScript + tsup. Components like are exported and used in a separate consuming application. However, the Tailwind classes do not apply when using the library components. For example: export default defineConfig({ export default { Questions : |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Yes, have a CSS file in the library that has any neccessary The consumer would then So bare minimum: /* library/dist/index.css */
@source "./";/* consumer/src/index.css */
@import "tailwindcss";
@import "library/dist/index.css";Notice how the libary's CSS is uncompiled. We leave the compilation to the consumer.
No.
No. |
Beta Was this translation helpful? Give feedback.
-
|
If the component library is also based on TailwindCSS v4, then consider not shipping production-ready CSS in the library. Instead, import the source CSS, and TailwindCSS will map the library’s components using This can be taken even further: for example, if you have 1000 components but you only use 10 of them, it's beneficial if the unused 990 components' CSS does not end up in the production build. With |
Beta Was this translation helpful? Give feedback.
Since the CSS is in its own folder, you'd want to change the
@sourceto cover your components. You'd also want to remove@import "tailwindcss";from it: