【问题标题】:How to add css for properties in React Material UI如何在 React Material UI 中为属性添加 css
【发布时间】:2018-07-23 11:08:41
【问题描述】:
这里我使用了<AppBar/> 和iconElementRight 之类的属性。在浏览器中检查时,我可以看到 iconElementRight 是单独的 div。我需要为iconElementRight 添加边距。谢谢...
<div>
<AppBar
title="Component Catalog"
iconElementRight={<img src={require('../../assets/images/logo-footer.png')} alt="logo" />}
style={{ border: '1px solid black' }}
/>
</div>
【问题讨论】:
标签:
reactjs
react-native
react-router
react-redux
material-ui
【解决方案1】:
Material-ui AppBar 有一个名为 iconStyleRight 的道具,它覆盖右侧元素的内联样式,您可以像这样使用它
<div >
<AppBar title="Component Catalog"
iconElementRight = {<img src={require('../../assets/images/logo-footer.png')} alt="logo"/>}
iconStyleRight={{ margin: '10px' }}
style={{border:'1px solid black'}}
/>
</div>
【解决方案2】:
您可以使用 AppBar 的 iconStyleRight 或 iconClassNameRight 属性为图标 div 添加自己的样式。
可以参考Material AppBar的属性