-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cannot apply PrimeReact styled theme to NextJS 14 with Tailwind #5291
Comments
I think its an issue with CodeSandbox/StackBlitz. See this solution: #4987 (comment) |
Ok I tried specifying imports in that order (tailwind with layers first, then primereact) (see reproducer):
but so far no changes. The truth is that first I tried on my local setup, and with (*) even though there is something weird like the red X in the Message component when the page loads appears in the top left corner and a few ms later it appears in the correct position, it is something ugly noticeable by the user. Thank you |
Yep @SoyDiego has a solution for this |
Try this: https://soydiego.notion.site/PrimeReact-How-to-fix-styles-NextJS-Tailwind-92bec3eb91594388a7be67d922460eaf |
Thank you @SoyDiego, I confirm that (weirdly enough :)) it works on dev environment. Can you try if workarounds 1 and 2 work for you on production env? |
Yes, I have in production. Check if the styles are being applied in your head tag, inspecting the code. |
Ok with workaround 1 I can see them in production with the correct order, with workaround 2 they are inverted. Thank you! |
I guess I have the same problem. No PrimeReact components were style properly even in dev mode. It looks like that Nextjs strips all classes that are not used directly in Nextjs app. Adding this to tailwind.config.ts seems to preserve all classes in css:
|
doesn't work for me, also that From what I have understood the css classes are not stripped, is the layer ordering that gets messed up so tailwind overwrite primereact styles |
A few thoughts on this:
|
@kabalan-datapostie I believe this has been addressed and fixed in NextJS as of May 1, 2024 --> vercel/next.js#13092 CC @melloware |
Thanks @gcko closed! |
Describe the bug
I started a brand new NextJS 14 app with App Router and Tailwind automatically set up by NextJS.
Then I added PrimeReact, with the mdc theme, and configured Tailwind as explained here: https://primereact.org/tailwind/ in the styled part.
However I got something mixed that doesn't appear to be working, see reproducer: Tailwind works (the classes are successfully applied), PrimeReact components work, but the PrimeReact mdc theme doesn't seem to apply, the button is transparent, the inputs are weird as well.
Could you please check the reproducer to verify whether I did something wrong or if that is indeed a bug?
Thanks a lot
Reproducer
https://stackblitz.com/edit/stackblitz-starters-i1ylh3?file=package.json
PrimeReact version
10.0.9
React version
18.x
Language
TypeScript
Build / Runtime
Next.js
Browser(s)
No response
Steps to reproduce the behavior
No response
Expected behavior
No response
The text was updated successfully, but these errors were encountered: