[material-ui][docs] NextJS app router CSS injection order #40138
Labels
docs
Improvements or additions to the documentation
nextjs
package: material-ui
Specific to @mui/material
Duplicates
Related page
https://mui.com/material-ui/guides/next-js-app-router/#css-injection-order
Kind of issue
Unclear explanations
Issue description
I'm customizing Material UI styles via CSS modules, so I need to inject them before the MUI emotion styles as described in the doc; however, the example linked at the top of the doc (https://github.com/mui/material-ui/tree/master/examples/material-ui-nextjs-ts) uses much different code than the rest of the code samples in the doc, and it seems the
prepend: true
option is deprecated in favour ofinsertionPoint
, but it isn't clear how to achieve the same effect with the latter.I tried changing the following in
EmotionCache.tsx
from the linked example repo:And this sort of works, but the injection order is only correct some of the time when reloading the page. Maybe 10% of regular reloads and 30% of hard reloads. When not injected properly, the emotion styles are not applied with
@layer
for some reason.This clarification was also requested here: #37315 (comment).
Context 🔦
No response
The text was updated successfully, but these errors were encountered: