简体   繁体   中英

Material-UI Change Drawer Color

How to set background color of Material-UI Drawer? tried this, but doesn't work

const styles = {
  paper: {
    background: "blue"
  }
}

and passed it to the Drawer component:

 <Drawer
      classes={{ paper: classes.paper }}
      open={this.state.left}
      onClose={this.toggleDrawer("left", false)}
    >

and wrapped my component with material-ui's withStyles

export default withStyles(styles)(ResponsiveDrawer);

Here is the code in the sandbox .

Change the attribute background to backgroundColor . Like this:

const styles = {
  paper: {
    backgroundColor: "blue"
  }
}

The problem that you have is you're passing a [Object object] as className to Drawer component because you're using styles rather than classes. Try to pass a string className to your component.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM