Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a body background image in MuiThemeProvider

Tags:

material-ui

I have a react app with Material UI. I know how to set the theme's default background color on body. However, I want to set a background image instead. How can I accomplish this?

const theme = createMuiTheme({
  palette: {
    background: {
      default: ???
    }
  }
});
like image 455
Helder Esteves Avatar asked Mar 04 '23 04:03

Helder Esteves


1 Answers

If you are using CssBaseline you can apply a global style through theme overrides and set the backgroundImage for body e.g. https://codesandbox.io/s/v30yq681ql. You should be able to set the global style through any component that you are using.

like image 96
Josh Wooding Avatar answered Apr 09 '23 20:04

Josh Wooding