【发布时间】:2020-12-06 15:17:44
【问题描述】:
目标
根据悬停期间的值更改评级(材质 UI 组件)的颜色。例如,如果我将鼠标悬停在第 1 颗星上,颜色变为红色,如果悬停在第 5 颗星上,则变为绿色。
我尝试过制作一个自定义组件,它会在悬停时改变颜色,就像这样 -
const StyledRating = withStyles({
root: {
color: "#ff6d75",
},
iconFilled: {
color: '#ff6d75',
},
iconHover: {
color: '#fff',
backgroundColor: "#000",
},
})(Rating);
但它会改变所有图标的颜色。
谁能指导我,如何根据我选择或悬停在上面的值更改评级颜色中的特定图标。
【问题讨论】:
标签: reactjs typescript material-ui material-design gatsby