I'm trying to map out a menu with icons in Material UI
its working, but I do not understand how to pass the sx prop into the Icon when using the map function.
this is an example
export const Menuitems = [
{
name: 'Dashboard',
to: '/',
text: 'dashboard',
icon: (<DashboardIcon />),
},
{
name: 'Pretest',
to: '/pretest',
text: 'pretest',
icon: (<AccessibilityIcon />),
},
]
export const ShowMainMenu = (props) => {
return (
<Grid item >
<Link style={{ textDecoration: "none" }} to={props.to}>
<Paper elevation={6}>
{props.icon}
<Typography fontSize={20} fontWeight={600}>{props.name}</Typography>
</Paper>
</Link>
</Grid>
in another component, I map over the Menuitems with spread like this:
<Grid container >
{ Menuitems.map((item) => {
return <ShowMainMenu {...item} />
})
}
</Grid>
This works fine, but I need to change the size of the Icons with a sx prop.
I would like to have it like this:
<DashboardIcon sx={{color: '#002884' , fontSize: 80 }}/>
I would prefer not to put styling into the menu-array because I use it in many different settings, so I would like to keep it clean.
Does anyone have any suggestions on how to use the sx prop in this context?