If you want to customize the styling of your menu in Material-UI, you can utilize the classes
property within the <Menu />
component.
For detailed information on CSS customization, refer to the CSS section on https://material-ui.com/api/menu/
The classes property allows you to pass an object with keys representing the style rules you wish to modify.
To override default paper styles, you can do so by following this structure:
<Menu
id="simple-menu"
open={true}
classes={{
paper: classes.custom
}}
>
An illustrative example could be constructed as shown below:
import React from "react";
import Menu from "@material-ui/core/Menu";
import MenuItem from "@material-ui/core/MenuItem";
import { makeStyles } from "@material-ui/core/styles";
function App() {
const useStyles = makeStyles({
custom: {
borderColor: "green",
borderWidth: "2px",
borderStyle: "solid"
},
list: {
backgroundColor: "yellow"
}
});
const classes = useStyles();
return (
<Menu
id="simple-menu"
open={true}
classes={{
paper: classes.custom,
list: classes.list
}}
>
<MenuItem>Item 1</MenuItem>
<MenuItem>Item 2</MenuItem>
<MenuItem>Item 3</MenuItem>
</Menu>
);
}
export default App;