-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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
[wip][system] Try reordering the presedence of variants over base styles #42276
base: next
Are you sure you want to change the base?
Conversation
Netlify deploy previewhttps://deploy-preview-42276--material-ui.netlify.app/ packages/material-ui/material-ui.production.min.js: parsed: +0.17% , gzip: +0.09% Bundle size reportDetails of bundle changes (Toolpad) |
], | ||
}); | ||
|
||
const B = styled(A)({ |
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 the use-case that still doesn't work - using the styled() util.
root: { | ||
paddingTop: '20px', | ||
// this should not override the one from A | ||
backgroundColor: 'rgb(255, 255, 255)', |
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.
Controlling the order of the styleOverrides is possible, as we are the one that handles when these are added.
We discussed internally how the precedence of overrides should work with the new variants API (the discussion started around the Pigment CSS product, see more info here).
From the initial investigation, it is possible for us to dictate how the order of the base styles/variants are handled along one instance of component, styled(), styleOverrides, variants, however, I didn't find a way how to augment the order of how they are added across components, for example using styled(Button). Check the tests for more details (I skipped the one that is not working).
Considering it is not possible to do it consistently between theme vs styled() overrides, I would lean toward not implementing any change and document this as a different behavior between Pigment CSS and MUI System and add instructions around best practices of how the overrides should be written so that people know how to not get into this kind of differences in behavior.