Recently, I made a small change in my approach to styling by moving CSS directly into my component files using styled components, emotion, and make styles. This decision was driven by the benefits of easier management and improved development experience. As I experimented with this new method on a dummy project and then on some components of a current app I'm working on, I encountered an issue with overriding existing Material-UI styles.
For instance, while creating an accordion component using Material-UI, I came across a nested property:
.MuiAccordionSummary-root.Mui-expanded {
min-height: 64px;
}
Adjusting this in my sass file would have been simple, but I struggled to figure out how to implement it using make styles.
My current styles are structured like this:
const useStyles = makeStyles((theme) => ({
root: {
borderBottom: '0.5px solid',
borderBottomColor: theme.palette.primary.main,
marginBottom: '16px',
maxHeight: '35px',
},
summary: {
backgroundColor: theme.palette.complimentory.main,
borderBottom: '0.5px solid',
borderBottomColor: theme.palette.primary.main,
maxHeight: '35px',
height: '35px',
},
title: {
fontFamily: 'Helvetica',
fontStyle: 'normal',
fontWeight: 'normal',
fontSize: '14px',
lineHeight: '14px',
letterSpacing: '0.266667px',
textTransform: 'uppercase',
},
content: {
marginTop: '15px',
fontSize: '14px',
fontStyle: 'normal',
lineHeight: '16.8px',
letterSpacing: '0.375px',
fontWeight: '400',
fontFamily: 'Helvetica',
textAlign: 'left',
},
}))
I am struggling to target the specific MuiAccordionSummary element inside makestyles. It seems possible, but I'm finding it challenging due to my lack of familiarity with this method.