【问题标题】:How to change background color of drawer component materialui in react?如何在反应中更改抽屉组件材质ui的背景颜色?
【发布时间】:2020-10-01 12:16:39
【问题描述】:

我想在 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文件中的一个类来强制它,但它没有用....

【问题讨论】:

    标签: css reactjs material-ui react-navigation-drawer


    【解决方案1】:

    瞄准Drawerpaper

    const useStyles = makeStyles({
      MuiDrawer: {
        backgroundColor: "#5d001e"
      }
    });
    
    <Drawer
      classes={{paper: classes.MuiDrawer}}
    >
    

    【讨论】:

      猜你喜欢
      • 2019-01-17
      • 2018-09-06
      • 2021-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 2018-06-05
      • 1970-01-01
      相关资源
      最近更新 更多