如何减少材质UI中星星之间的间隙

时间:2018-09-20 13:21:36

标签: reactjs material-ui

我正在努力缩小星星之间的距离,但没有运气。

以下代码供您参考

 <MuiThemeProvider  >
                            <Rating
                                onChange={() => console.log('onChange')}
                                value={4}
                                max={5}
                                iconFilled={<ToggleStar  color={colors.green500} />}
                                iconHovered={<ToggleStarBorder  color={colors.green500} />}
                                iconNormal ={<ToggleStarBorder color={colors.black300}/>}
                                className={classes.Rating}
                                 spacing ={0}
                                onChange={(value) => console.log(`Rated with value ${value}`)}
                              />
                        </MuiThemeProvider > 

我该如何解决?

1 个答案:

答案 0 :(得分:0)

使用itemStyleitemIconStyle道具:

const smallDistanceStyle = {
  width: 30,
  height: 30,
  padding: 5
}

const iconStyle = {
   width: ...,
   height: ...
}

<Rating
  itemStyle={smallDistanceStyle}
  itemIconStyle={iconStyle}
  ...
/>