Cannot override MUI icon default styling when using 5.0 beta.
See original GitHub issueI cannot increase the font-size
of an MUI icon.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
MUI styling is overriding custom styling
Expected Behavior 🤔
Custom styling should override default MUI styling
Steps to Reproduce 🕹
This sandbox shows a icon with custom styling that overrides the default styling (which is correct):
https://codesandbox.io/s/intelligent-dewdney-1t832?file=/src/Demo.tsx
"@emotion/react": "11.4.1",
"@emotion/styled": "11.3.0",
"@material-ui/core": "4.12.3",
"@material-ui/icons": "4.11.2",
"@material-ui/styles": "4.11.4",
"react": "latest",
"react-dom": "latest",
"react-scripts": "latest"
But when certain packages are upgraded the default styling starts to override the custom styling:
https://codesandbox.io/s/heuristic-scott-5z5ng?file=/package.json
"@emotion/react": "11.4.1",
"@emotion/styled": "11.3.0",
"@material-ui/core": "5.0.0-beta.5",
"@material-ui/icons": "5.0.0-beta.5",
"@material-ui/styles": "5.0.0-beta.5",
"react": "latest",
"react-dom": "latest",
"react-scripts": "latest"
Updating all material ui packages doesn’t help either:
https://codesandbox.io/s/hopeful-lalande-x27e0?file=/src/Demo.tsx
"@mui/icons-material": "5.0.0-rc.1",
"@mui/material": "5.0.0-rc.1",
"@mui/styles": "5.0.0-rc.1",
Only this method seems to work: <AccountCircle style={{ fontSize: 40 }}/>
Context 🔦
Trying to increase a MUI icon fontsize so I can use it as a button.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Cannot override default Material UI Icon styling - Stack Overflow
Cannot override default Material UI Icon styling · It works using version 4.12. · Just recreated the issue in a codesandbox codesandbox.io/s/ ...
Read more >Can't override IconButton styles in theme without affecting ...
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >Struggling to override some of the default styling in Material UI ...
I'm currently trying to change the padding on an MUI Button component but it doesn't seem to be working as the MUI styling...
Read more >Migrating to v5: getting started - Material UI - MUI
One of the biggest changes in v5 is the replacement of JSS for Emotion as a default styling solution. Note that you may...
Read more >mui-datatables - npm
Start using mui-datatables in your project by running `npm i ... doesn't already use them, you need to install mui v5 and it's...
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 Free
Top 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
Sorry I didn’t notice that the last example was using
style
.Here is a working sandbox: https://codesandbox.io/s/laughing-alex-nyszr?file=/src/index.tsx
Note that you need to wrap your app with
StyledEngineProvider
with inject first so that the emotion styles would be injected before the JSS ones. This is documented in the Styled library interoperability guide - https://mui.com/guides/interoperability/There are four ways of how you can do this:
I hope this helps
Sorry for the late response. If you use v5 with the recommended v5 styling mechanism you don’t need StyledEngineProvider, StyledProvider nor ThemeProvider if you are using the default theme.