Skip to content

Changes in CSS file do not update Next.js setup #17288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
killthecreator opened this issue Mar 19, 2025 · 6 comments · Fixed by #17301
Closed

Changes in CSS file do not update Next.js setup #17288

killthecreator opened this issue Mar 19, 2025 · 6 comments · Fixed by #17301

Comments

@killthecreator
Copy link

Image

Section says that i can use CSS variables directly. It might be true in case of static theme, but it does not work for custom non-static theme which gets only the values picket up by the scanner from classnames.

The confusion is that it is never mentioned, that scanner does not pickup CSS variables used directly to include them in a server theme layer:

Image

Image

@philipp-spiess
Copy link
Member

philipp-spiess commented Mar 19, 2025

Hey there! This seems like a bug on our end, I agree that this should just work. We'll look into it.

In the mean time, can you maybe share the contents of the file that references the CSS variable? I want to make sure we add a test case for your setup 👍 Also curious what extension you are using? Vite/CLI/PostCSS or something else?

@philipp-spiess philipp-spiess transferred this issue from tailwindlabs/tailwindcss.com Mar 19, 2025
@killthecreator
Copy link
Author

Hey there! This seems like a bug on our end, I agree that this should just work. We'll look into it.

In the mean time, can you maybe share the contents of the file that references the CSS variable? I want to make sure we add a test case for your setup 👍 Also curious what extension you are using? Vite/CLI/PostCSS or something else?

Hey there, thank you so much for a quick reply.

My setup is:
"next": 14.2.14 (therefore PostCSS extension)
"tailwindcss": 4.0.14
"@tailwindcss/postcss": 4.0.14
"postcss": 8.4.41

Issue persists both in client and server components

App server is ran within docker container

@killthecreator

This comment has been minimized.

@killthecreator killthecreator changed the title Confusing section about Referencing in JavaScript Directly used CSS variables declared in @theme do not update theme layer on change within docker container Mar 19, 2025
@killthecreator killthecreator changed the title Directly used CSS variables declared in @theme do not update theme layer on change within docker container Directly used CSS variables declared in @theme aren't update theme layer on change within docker container Mar 19, 2025
@killthecreator killthecreator changed the title Directly used CSS variables declared in @theme aren't update theme layer on change within docker container Directly used CSS variables declared in @theme don't update theme layer on change for containerized app Mar 19, 2025
@killthecreator killthecreator changed the title Directly used CSS variables declared in @theme don't update theme layer on change for containerized app Directly used CSS variables declared in @theme don't update theme layer on change for Next.js app Mar 19, 2025
@killthecreator
Copy link
Author

killthecreator commented Mar 19, 2025

Update:
I created a dummy Next.js App (sorry, should have tested with such minimal settings initially). Turns out containerization is not the issue, but it does not update in Next.js app in general.

How to reproduce:

  1. Create Next.js app via npx create-next-app@latest and start a server

  2. set two random variables in @theme in global.css file
    e.g.
    @theme { --color-background: red; --color-foreground: pink; }

  3. Go to any component a try to render a plain <div />.

  4. Add a style to that div with CSS var as <div style={{ color: "var(--color-foreground)" }}/>

  5. Notice that static CSS file is not refreshed therefore CSS Var is not added.

  6. Try to save (with or without changes) any .css file and notice that it refreshes static CSS file

  7. Try to change variable and notice that until you save .css file or restart the server the variable is not picked up

@killthecreator killthecreator changed the title Directly used CSS variables declared in @theme don't update theme layer on change for Next.js app Directly used CSS variables declared in @theme don't update theme layer on files change Mar 19, 2025
@killthecreator
Copy link
Author

Update:

I've setup a dummy vite project and tested all the steps above. Issue still persists. Workaround currently is the same: restart vite server or save any .css file

@philipp-spiess philipp-spiess changed the title Directly used CSS variables declared in @theme don't update theme layer on files change Changes in CSS file do not update Next.js setup Mar 20, 2025
@philipp-spiess
Copy link
Member

@killthecreator Thanks a ton for the report. We looked into it and will get a fix out for it today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants