Skip to content
Advertisement

Tailwindcss not working with next.js; what is wrong with the configuration?

For some reason, tailwind is not rendering properly in next.js.

I’m wondering if something is wrong with my settings?

Styles folder – tailwind.css

@tailwind base;

JavaScript

….

_app.js

JavaScript

What am I doing wrong? so confused, usually this sort of setup is fine.

This is the site btw – https://moodmap.app/ .

using the information below, made changes and still same issue weirdly.

https://moodmap.app/ is the site example.

tailwind.config.js

JavaScript

postcss.config.js

JavaScript

Thanks!

Advertisement

Answer

I think your setup is too big. You can achieve this with much simpler stuff nowdays.

First, I don’t think CSS needs to be loaded into nextjs anymore and modules are supported natively. (So you can delete this withCSS stuff)

Second, tailwind doesn’t need such elaborate setup anymore, if you are using the newer versions.

So you will need to install postcss-preset-env, but it does remove the need for big config now.

Check out this example https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement