Next.js Discord

Discord Forum

When I implement a `app/not-found.tsx` file styling (tailwind) doesn't work.

Unanswered
Southern yellowjacket posted this in #help-forum
Open in Discord
Southern yellowjacketOP
When opening the inspector it appears none of my css files are being loaded. <head> is empty, except for a polyfills.js script. So all styling of the layout.tsx is also missing.

3 Replies

Southern yellowjacketOP
I dont have a public repo at hand, but I figured out that when I put 'use client' in the top of my not-found.tsx along with again importing my ../styles/globals.css which contains the tailwind imports it works. Somehow this feels backwards to me, since my layout gets loaded and is importing that as well.
That is indeed weird, if the layout wrapping not-found imports the css it should work.

A structure like this won’t work, however
app/
  layout.tsx <- css is not imported here
  not-found.tsx
  (whatever)/
    layout.tsx <- css is imported here