Styled-components doesn't work with Material UI
See original GitHub issueStyled-components doesn’t work with Material UI
I’m trying to style material-ui component using styled components and doesn’t work
Example of code:
import Button from 'material-ui/Button';
const StyledButton = styled(Button)`
background: red;
border: 1px solid red;
font-size: 2rem;
font-weight: bold;
`;
class ButtonTemplate extends Component {
render() {
return(
<div>
<StyledButton />
</div>
)
}
}
I get only the normal styling of material UI button…what’s is the issue?
Thanks, Lucas
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:18 (6 by maintainers)
Top Results From Across the Web
styled-components doesn't work with material-ui
hi friends, i am using material-ui with reactjs to create a website, then i want to add my custom style with help styled-component...
Read more >New Material-UI v5 not working with styled-components and ...
62 votes, 28 comments. I'm trying to use the new Material-UI v5 that just came out but am having trouble using it with...
Read more >Style library interoperability - Material UI - MUI
If you are already using a custom theme with styled-components or Emotion, it might not be compatible with MUI's theme specification. If it's...
Read more >How to Styled Component in Material UI #31 - YouTube
Material UI Playlist: https://www.youtube.com/playlist?list=PLlR2O33QQkfXnZMMZC0y22gLayBbB1UQdHey Everyone,In this video you will be able to ...
Read more >Styled Components in Material UI (MUI) with Styled Utility
Always make sure that the first letter of the variable is capital because it will work like a component and a component name...
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
There’s a guide here: https://www.styled-components.com/docs/advanced#existing-css
Also, you can try to increase the specificity of your SC CSS:
Looks like we have 3 ways (could be easier, but not everything is flowers) to override Material UI styles with Styled Components. Here is my Gist.