[pigment-css] Externally defined classname styles not loading correctly when using Next.js #44929
Labels
nextjs
package: system
Specific to @mui/system
status: waiting for maintainer
These issues haven't been looked at yet by a maintainer
Steps to reproduce
There are the following repositories where you can try to reproduce this issue:
https://github.com/jooy2/nextart
npm i
npm run dev
First, notice that the button is black on the main page (
/
). Refresh (F5) and the button should still be black.Then, without refreshing, click the button to go to the second page. The second page has the same style applied, so the button will be black.
However, if you do a refresh on the second page with this state, the button will be unstyled and blue.
Buttons should appear black in all situations, such as refreshing and switching routing.
Current behavior
The button doesn't apply the customized style in certain situations.
Expected behavior
Buttons should appear black in all situations, such as refreshing and switching routing.
Pigment-css also need to be able to use the styles you define in the external file.
Context
Buttons with external styles in a client component do not seem to be applied when the page is loaded.
However, as an exception, if the styles applied to that component are defined in the same file, the problem is not reproduced.
In my current implementation, this is the situation with the client component code:
The
cssBlackButton
was defined in an external file:I haven't reviewed everything, but this seems to happen most notably with the Button component (ButtonBase).
Maybe I missed some setting or migration item in pigment-css or material-ui. Or maybe this is what was intended, I don't know.
I would like to know if this is a valid issue and if there is a workaround at this time. Thank you for your help.
Your environment
npx @mui/envinfo
Search keywords: pigment-css,nextjs,client-component,external-file
The text was updated successfully, but these errors were encountered: