[system] pseudo class overridden in slot
See original GitHub issuev4: https://codesandbox.io/s/exciting-matsumoto-no6lr?file=/src/App.js OK
v5: https://codesandbox.io/s/friendly-pasteur-e0q3t?file=/src/App.js KO
This is a regression in v5.
Take a look at this Button theme example.
const theme = createTheme({
components: {
MuiButton: {
styleOverrides: {
contained: {
'&.Mui-disabled': {
opacity: 0.65
}
},
containedPrimary: {
'&.Mui-disabled': {
color: "#fff",
backgroundColor: palette.primary.main,
}
}
}
}
}
})
<Button variant="contained" disabled />
// opacity 0.65
<Button variant="contained" color="primary" disabled />
// opacity is gone
This is because &.Mui-disabled
in contained
is overridden by containedPrimary
from the implementation in Button.js
.
// Button.js
...
overrideResolver: (props, styles) => {
return {
...styles[styleProps.variant],
...styles[`${styleProps.variant}${capitalize(styleProps.color)}`],
}
})
...
This makes customization harder because developer needs to know which key has higher priority.
The goal of this issue is to find a better DX to support theme customisation.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:5 (5 by maintainers)
Top Results From Across the Web
[system] pseudo class overridden in slot · Issue #26813 - GitHub
This is because &.Mui-disabled in contained is overridden by containedPrimary from the implementation in Button.js . // Button.js ...
Read more >slotted() - CSS: Cascading Style Sheets - MDN Web Docs
The ::slotted() CSS pseudo-element represents any element that has been placed into a slot inside an HTML template (see Using templates and ...
Read more >Override pseudo class elements bootstrap - Stack Overflow
In the above SCSS code I've tried to change the pseudo element content "/" to ">>" but the code is not working for...
Read more >How to customize - Material UI - MUI
First, use your browser's dev tools to identify the class for the component slot you want to override. The styles injected into the...
Read more >Importance of CSS Specificity and its best practices
The second slot is incremented by: Class selectors; pseudo-class selector; attribute selector. Whenever a rule meets the one of above mentioned ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I strongly think that we should support. To me it is what I normally do in v4 and if we don’t support, migration to v5 could be frustrating because it is not only about
Button
or psuedo class, it is about the same key that get overridden in the object.Moved to #26944