Skip to content
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

[docs] Create NextJS 14 example with Tailwind CSS #39883

Closed
wants to merge 3 commits into from

Conversation

orafaelfragoso
Copy link

Adding an example on how to use NextJS 14 with Material UI and Tailwind CSS, which also fixes the FOUC when overriding Material UI styles with Tailwind on SSR and client.

Adding an example on how to use NextJS 14 with Material UI and Tailwind
CSS, which also fixes the FOUC when overriding Material UI styles with
Tailwind on SSR and client.
@mui-bot
Copy link

mui-bot commented Nov 15, 2023

Netlify deploy preview

https://deploy-preview-39883--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 234ae2a

@orafaelfragoso orafaelfragoso changed the title [material-ui][examples] Create NextJS 14 example with Tailwind CSS [docs] Create NextJS 14 example with Tailwind CSS Nov 15, 2023
@orafaelfragoso
Copy link
Author

@oliviertassinari As we discussed on Twitter. I'm just not sure how to add labels to the PR though.

@zannager zannager added the docs Improvements or additions to the documentation label Nov 15, 2023
@mnajdova mnajdova added examples Relating to /examples nextjs labels Nov 17, 2023
@mnajdova
Copy link
Member

Thanks for creating the example. Don't we need the ThemeRegistry for emotion to work as expected as in the other next.js examples?

@orafaelfragoso
Copy link
Author

Thanks for creating the example. Don't we need the ThemeRegistry for emotion to work as expected as in the other next.js examples?

Yes. It's all inside mui-provider.

@mnajdova
Copy link
Member

@orafaelfragoso
Copy link
Author

@mnajdova Added the emotion cache as asked. Sorry the delay.

@@ -9,6 +9,12 @@ import ChevronRightRoundedIcon from '@mui/icons-material/ChevronRightRounded';
import CloudRoundedIcon from '@mui/icons-material/CloudRounded';

const examples = [
{
name: 'Next.js 14',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be specific about this to avoid confusion

Suggested change
name: 'Next.js 14',
name: 'Next.js 14 with Tailwind CSS',

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this example shouldn't be the first one on the list? It makes more sense to me for the examples without Tailwind to come first.

As of Next.js 13.4, the newer App Router pattern is stable.

The project uses [Next.js](https://github.com/vercel/next.js), which is a framework for server-rendered React apps.
It includes `@mui/material` and its peer dependencies, including [Emotion](https://emotion.sh/docs/introduction), the default style engine in Material UI v5.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add another line explaining that Tailwind CSS is also properly configured to work with Material UI?


export function MuiProvider({ children }: MuiProviderProps) {
return (
<NextAppDirEmotionCacheProvider options={{ key: 'mui' }}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZeeshanTamboli
Copy link
Member

This would close #40802. However, since this PR has been open for a while and we now point to next for PRs, changing the base branch will be complicated with many changes. @orafaelfragoso, if you want to continue working on this, please create a new PR. I'll close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation examples Relating to /examples nextjs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants