【问题标题】:React, Mui Rating ComponentReact,Mui 评级组件
【发布时间】:2021-09-16 08:12:06
【问题描述】:

我最近正在使用 react 进行一个项目。我想知道是否有办法使用自定义颜色为评级的 Material-UI 组件着色。

【问题讨论】:

标签: reactjs material-ui


【解决方案1】:

其实你可以有任何你喜欢的图标形状或颜色

看看这个来自Material UI site的例子:

【讨论】:

    【解决方案2】:

    你可以使用这个例子

    material-ui.com/components/rating/customize

    并以您喜欢的颜色创建一个 costm 组件

    smt 像这样

    const StyledRating = withStyles({
      iconFilled: {
        color: 'red',
      },
      iconHover: {
        color: 'darkred',
      },
    })(Rating);
    

    【讨论】:

    • 谢谢...我的想法是为每个 iconFilled 元素赋予不同的颜色。可以这样做吗?
    • 很可能是的,你能看到这个例子吗codesandbox.io/s/…
    猜你喜欢
    • 2021-12-16
    • 2022-06-29
    • 2022-06-28
    • 2012-08-15
    • 2023-01-26
    • 1970-01-01
    • 2022-07-18
    • 2019-04-13
    • 2019-07-28
    相关资源
    最近更新 更多