【问题标题】:How to apply inline css in Button using Material UI如何使用 Material UI 在 Button 中应用内联 CSS
【发布时间】:2019-08-11 03:17:12
【问题描述】:
const styles = {
    bgColor:{
        backgroudColor: '#f9a825'
    }
}

<Button color='primary' classes={fab:classes.bgColor} variant="fab" aria-label="Checkout"> Click Here </Button>

在这里,我想更改背景颜色。它的应用,但它优先于 Theme css。

【问题讨论】:

    标签: material-ui react-material


    【解决方案1】:
    1. classes 属性应用不正确。
    2. 你甚至不应该使用classes,因为你似乎没有注入任何东西;你应该使用style
    <Button color="primary"
            style={styles.bgColor}
            variant="fab"
            aria-label="Checkout">
        Click Here
    </Button>
    

    如果你确实将classes 注入到你的组件中,你可以这样使用它:

    <Button color="primary"
            classes={{ fab: classes.bgColor }}
            variant="fab"
            aria-label="Checkout">
        Click Here
    </Button>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-15
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      • 2018-09-25
      • 2017-07-29
      • 1970-01-01
      • 2019-07-21
      相关资源
      最近更新 更多