-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
[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
base: master
Are you sure you want to change the base?
Conversation
@@ -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)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…/tailwind-integration
|
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- pass a custom cache with `{ enableCssLayer: true }` to `documentGetInitialProps` function. | |
- enable the CSS layer feature |
Same as above.
@import 'tailwindcss'; | ||
``` | ||
|
||
### Next.js Pages Router |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
closes #44700
Docs: https://deploy-preview-45906--material-ui.netlify.app/material-ui/integrations/tailwindcss/tailwindcss-v4/
v3
to the guide in "Style library interoperability" sectionTry it out
For Next.js Pages Router, the latest
7.0.2
won't work because [material-nextjs] Add option to enable CSS layers for pages router #45596 is not released yet, so please use the build below:For App Router, the latest version
7.0.2
should work.