如何在反应中更改抽屉组件materialui的背景颜色?
How to change background color of drawer component materialui in react?
我想在 React 中更改抽屉组件的背景颜色,但我总是只能更改抽屉后面的整个背景,即带有项目的字段,或者只能更改整个白色区域。这是我的代码:
const useStyles = makeStyles({
MuiDrawer: {
backgroundColor: "#5d001e",
},
list: {
width: 250,
},
linkText: {
textDecoration: `none`,
textTransform: `uppercase`,
color: `black`,
},
})
return (
<>
<React.Fragment>
<TheIconButton
edge="start"
aria-label="menu"
onClick={toggleDrawer("right", true)}>
<Menu />
</TheIconButton>
<Drawer anchor="right" open={state.right} onOpen={toggleDrawer("right", true)} onClose={toggleDrawer("right", false)} className={classes.MuiDrawer}>
{sideDrawerList("right")}
</Drawer>
</React.Fragment>
</>
)
关于如何定位它有什么想法吗?我也尝试在 css 文件中用 class 强制它,但它没有用....
定位 Drawer
paper
const useStyles = makeStyles({
MuiDrawer: {
backgroundColor: "#5d001e"
}
});
<Drawer
classes={{paper: classes.MuiDrawer}}
>
我想在 React 中更改抽屉组件的背景颜色,但我总是只能更改抽屉后面的整个背景,即带有项目的字段,或者只能更改整个白色区域。这是我的代码:
const useStyles = makeStyles({
MuiDrawer: {
backgroundColor: "#5d001e",
},
list: {
width: 250,
},
linkText: {
textDecoration: `none`,
textTransform: `uppercase`,
color: `black`,
},
})
return (
<>
<React.Fragment>
<TheIconButton
edge="start"
aria-label="menu"
onClick={toggleDrawer("right", true)}>
<Menu />
</TheIconButton>
<Drawer anchor="right" open={state.right} onOpen={toggleDrawer("right", true)} onClose={toggleDrawer("right", false)} className={classes.MuiDrawer}>
{sideDrawerList("right")}
</Drawer>
</React.Fragment>
</>
)
关于如何定位它有什么想法吗?我也尝试在 css 文件中用 class 强制它,但它没有用....
定位 Drawer
paper
const useStyles = makeStyles({
MuiDrawer: {
backgroundColor: "#5d001e"
}
});
<Drawer
classes={{paper: classes.MuiDrawer}}
>