It appears that you are utilizing regular CSS, however material-UI utilizes JSS as their styling solution. You can explore their styling solutions here, and learn how to customize the CSS of components here.
You have the option to do this in your specific case.
import Menu from "@material-ui/core/Menu";
import { makeStyles } from "@material-ui/core/styles";
const useStyles = makeStyles(theme => ({
paperMenu: {
color: "red"
},
menuMarginTop: {
color: "blue"
}
}));
export default function App(props) {
const classes = useStyles();
return (
<Menu
classes={{ paper: classes.paperMenu }}
className={classes.menuMarginTop}
/>
);
}
In this code snippet, classes.paperMenu
will override the underlying paper (component) class, while menuMarginTop
will be applied to the root element of the Menu component. Material-UI
generates unique class names randomly at runtime, so fixed class names cannot be relied upon like in other libraries. The only way to override the underlying class is by using the classes
prop, as explained further in the links above.
Keep in mind that this is just one method of overriding classes; there are alternative methods such as Higher Order Components like withStyles
or withTheme
. Additional information can be found in the provided links.