Skip to content

[docs] Add Tailwind CSS v4 integration guide #45906

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Apr 14, 2025

closes #44700

Docs: https://deploy-preview-45906--material-ui.netlify.app/material-ui/integrations/tailwindcss/tailwindcss-v4/

  • Added v3 to the guide in "Style library interoperability" section
  • Added a dedicated page for Tailwind v4 integration.

Try it out


@siriwatknp siriwatknp added the docs Improvements or additions to the documentation label Apr 14, 2025
@@ -18,7 +18,7 @@ export const replaceMaterialLinks = (url: string) => {
return url;
}
return url.replace(
/(guides|customization|getting-started|discover-more|experimental-api|migration)/,
/(guides|customization|getting-started|discover-more|experimental-api|migration|integrations)/,
Copy link
Member Author

Choose a reason for hiding this comment

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

Add this change to fix the wrong generated url of the deploy preview

image

In the image above, the material should be material-ui.

@mui mui deleted a comment from mui-bot Apr 14, 2025
@mui-bot
Copy link

mui-bot commented Apr 14, 2025

@siriwatknp siriwatknp marked this pull request as ready for review April 14, 2025 07:48
@siriwatknp siriwatknp requested a review from mnajdova April 14, 2025 11:40

Follow the [App Router guide](/material-ui/integrations/nextjs/#app-router) and do the following steps:

- pass `{ enableCssLayer: true }` to the `options` prop of `AppRouterCacheProvider` component.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- pass `{ enableCssLayer: true }` to the `options` prop of `AppRouterCacheProvider` component.
- enable the CSS layer feature

People will figure out what they need to do in the code-snippet bellow.


```tsx title="src/app/layout.tsx"
import { AppRouterCacheProvider } from '@mui/material-nextjs/v15-appRouter';
import GlobalStyles from '@mui/material/GlobalStyles';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import GlobalStyles from '@mui/material/GlobalStyles';

It's not used in the code.


Follow the [Pages Router guide](/material-ui/integrations/nextjs/#pages-router) and do the following steps:

- pass a custom cache with `{ enableCssLayer: true }` to `documentGetInitialProps` function.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- pass a custom cache with `{ enableCssLayer: true }` to `documentGetInitialProps` function.
- enable the CSS layer feature

Same as above.

@import 'tailwindcss';
```

### Next.js Pages Router
Copy link
Member

Choose a reason for hiding this comment

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

I couldn't make this work, I tried to follow the steps from the Next.js guide and this one, but Tailwind classes were not overriding the MUI styles. It would be great if we can have an example to link (together with the guides), as combining the two guides it's kind of hard to follow.

Also, I've created #45922 with bunch of issues I found on the Next.js guide.

Copy link
Member Author

@siriwatknp siriwatknp Apr 16, 2025

Choose a reason for hiding this comment

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

This is expected because we haven't release #45596.

Updated the PR description to make it clear what build to use.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, ok, I will update my testing app to use the build from that PR.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[material-ui] Opt-in support for @layer to fix Tailwind v4 integration
3 participants