-
Notifications
You must be signed in to change notification settings - Fork 85
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
Example for NextJS 14 and Tailwind with App Router #19
Comments
Issue has been asked under the Free Sakai React template as well: primefaces/sakai-react#47 And open issue: primefaces/primereact#5127 |
Has Next14 been able to integrate with Prime React and Tailiwind? |
+1 |
i got news. nextjs 13+ with app router and tailwind could work together without the layer thing. just need to import the css theme.css below the globals.css in layout file. i figure this out after i got no styling at all even after following the tailwind instruction, turns out i got it working after switching these line. // this is the wrong order
import "primereact/resources/themes/md-dark-indigo/theme.css";
import "./globals.css"; // this is the right order
import "./globals.css";
import "primereact/resources/themes/md-dark-indigo/theme.css"; |
Hey man, nice! Can you share a complete configuration for this? Do we still need the |
basically, no. The provider only hold state for components and themes, but the css only apply the style, and if the style applied in incorrect order, the tailwind will reset the primereact style cause it is tailwind behavior to reset any styling that applies before them. also, no need extra configuration, just import the css theme in correct order. altough, i haven't try with toggling theme with this solution, maybe you could override the style with dynamic import or something. |
@BanDroid i would love if you wanted to submit a PR for this example here in the examples folders because this gets asked a lot? |
others need to confirm if my solution works or not, it works with mine, but i'm not sure if this is working with someone else. |
The only way I managed to work is by adding preflight as false in my tailwind.config.ts but this is a huge nuclear bomb so is not a solution but a workaround.
I have no idea but this layers in global.css are doing jack.
The issue itself is with the tailwind, not primereact because if you remove the tailwind either by disabling the preflight or by removing the layers and leaving just your theme in your global.css, it suddenly works. @BanDroid, can you share a stackblitz so we can take a look? ❤️ |
SO... I was able to find a weird solution but I have NO IDEA why it works, I really don't understand. The usual global.css
You can go either way with provider or not.
Is this what you meant @BanDroid? We basically have to add the theme twice, one "dummy" and another one you actually want to use. edit: apparently the reason why I needed two of the imports is that you don't really need the import on the global.css like the documentation suggests. weird. Adding to the layout.tsx alone sort of works, I did a bunch of testing and I couldn't find anything wrong with it. Which is great. |
yes, this is what i mean, you dont exactly need to import primereact in globals.css, cause primereact classes and tailwind classes have different prefixes, it will be different case if you also use primefaces (seriously, why? 2 utility library?) so the logic would be like this tailwind (will reset browser style) -> primereact (will add primereact style) you could still use tailwind utility and color because the classname prefix are different, so just make sure globals.css (tailwind) will have to come first then primereact the second import. you could also use primereact utility together with tailwind using dynamic value.
|
Thanks to @BanDroid and @meowzhin a new sample has been added: https://github.com/primefaces/primereact-examples/tree/main/nextjs-app-router-styled-tailwind |
Trying to use the unstyled version like this:
Causes an error when trying to pass
|
the file where you create the |
Hi, do you mind updating (or adding) the examples with nextjs+tailwind, styled and unstyled, using the new App Router in v14? I'm struggling about configuring the new
layout.tsx
, I managed to use Primereact OR Tailwind, but not both together.Thank you
Regards
The text was updated successfully, but these errors were encountered: