简体   繁体   English

如何摆脱 Material-UI 主题中的阴影

[英]How to get rid of shadows in the Material-UI theme

I need to get rid of shadows in MuiPaper component.我需要摆脱 MuiPaper 组件中的阴影。

I found some solution: for example我找到了一些解决方案: 例如

but they didn't work.但他们没有工作。 I can override only root component (MuiPaper) but the shadow is set by the class MuiPaper-elevation1-24.我只能覆盖根组件(MuiPaper),但阴影由 class MuiPaper-elevation1-24 设置。

code that render component渲染组件的代码

 const List = props => ( <List {...props} title="lists" filters={<Filter />} sort={{ field: 'timestamps.createdAt', order: 'DESC' }}> <Datagrid rowClick="show" expand={<Edit />} > <TextField source="attributes.campaignUuid" label="Campaign Uuid" /> <TextField source="attributes.affiliateId" label="Affiliate Id" /> <DateField source="attributes.createdAt" label="Created At" showTime locales="ru-RU" sortBy="timestamps.createdAt" /> <DateField source="attributes.updatedAt" label="Updated At" showTime locales="ru-RU" sortBy="timestamps.updatedAt" /> <DeleteButton /> </Datagrid> </List> );
 And HTML that I receive: <div class="list-page Component-root-904"> <div class="MuiPaper-root-21 MuiPaper-elevation1-24 MuiPaper-rounded-22 MuiCard-root-740 Component-card-905"></div> </div>

Try this:尝试这个:

import { withStyles, createStyles } from '@material-ui/core/styles';

const listStyles = theme => createStyles({
  card: {
    boxShadow: 'none',
  },
});

const List = withStyles(listStyles)(({ classes, ...props }) => (
  <List classes={classes} title="lists" filters={<Filter />} sort={{ field: 'timestamps.createdAt', order: 'DESC' }} {...props}>
    ...
  </List>
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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