[v4] [vite] Internal server error: Could not resolve value for theme function: theme(...) #15366
-
I'm trying to use tailwindcss in a monorepo setup. I want to use the I'd like some input on what the best setup for this is. I've got it working, but I have to import the file that contains the
This feels a bit off. I would expect to be able to use the function without needing the import. Here is a simple example repo for reference. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey! We recently added a new feature to make this use case simpler: #15228 However, you'll still need to import a theme into each CSS root file that uses Tailwind features as there's no more global per-project JavaScript configuration file. If you're using something like CSS modules, there's going to be a lot of CSS roots that are independent of each other. We mentioned this in the docs in regards to Svelte/Vue setups which share a similar setup with different CSS files per component: https://tailwindcss.com/docs/v4-beta#using-apply-in-vue-svelte One thing to note in v4 though is that you can just use CSS variables from your root CSS file and won't have to use the |
Beta Was this translation helpful? Give feedback.
-
Thanks @philipp-spiess, I had found I think that the documentation here https://tailwindcss.com/docs/v4-beta#using-apply-in-vue-svelte could be rewritten to cover CSS roots in general. I initially skipped over that part of the documentation because I assumed that anything relating to Vue or Svelte was not applicable. |
Beta Was this translation helpful? Give feedback.
Hey! We recently added a new feature to make this use case simpler: #15228
However, you'll still need to import a theme into each CSS root file that uses Tailwind features as there's no more global per-project JavaScript configuration file. If you're using something like CSS modules, there's going to be a lot of CSS roots that are independent of each other. We mentioned this in the docs in regards to Svelte/Vue setups which share a similar setup with different CSS files per component: https://tailwindcss.com/docs/v4-beta#using-apply-in-vue-svelte
One thing to note in v4 though is that you can just use CSS variables from your root CSS file and won't have to use the
theme()
function except …