Material-ui: Unable to set default elevation for MuiPaper

Created on 14 Jan 2020  路  2Comments  路  Source: mui-org/material-ui

Setting the default elevation for MuiPaper in the theme using the documented method does not work. I can set other default properties of MuiPaper and they do work.

  • [x] The issue is present in the latest release.
  • [x] I have searched the issues of this repository and believe that this is not a duplicate. However i did find a relevant issue and commented on it but it was marked as off-topic.

Steps to Reproduce 馃暪

const theme = createMuiTheme({
  props: {
    MuiPaper: {
      elevation: 10,
      square: true
    }
  }
});

https://codesandbox.io/s/fancy-bird-ekr8b?fontsize=14&hidenavigation=1&theme=dark

Your Environment 馃寧

| Tech | Version |
| ----------- | ------- |
| Material-UI | v4.8.3 |
| React |16.11.0|
| Browser |Chrome 78|
| TypeScript |no|

question

Most helpful comment

@jpodpro Not sure if this will help you but Card uses a different default prop for elevation than Paper.

Try adding this:

    MuiCard: {
      elevation: 0
    }

If you look at Card.js They set the elevation based on a raised prop. So that's why you need to directly add an elevation to Card itself to override that.

https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Card/Card.js#L20

All 2 comments

@jpodpro Not sure if this will help you but Card uses a different default prop for elevation than Paper.

Try adding this:

    MuiCard: {
      elevation: 0
    }

If you look at Card.js They set the elevation based on a raised prop. So that's why you need to directly add an elevation to Card itself to override that.

https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Card/Card.js#L20

@KyruCabading thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbozan picture rbozan  路  3Comments

ghost picture ghost  路  3Comments

pola88 picture pola88  路  3Comments

iamzhouyi picture iamzhouyi  路  3Comments

FranBran picture FranBran  路  3Comments