reactjs 如何在MUI中为svg图标添加线性渐变填充?

huwehgph  于 2022-12-18  发布在  React
关注(0)|答案(1)|浏览(132)
<AutoModeIcon style={{background: 'linear-gradient(to right bottom, #430089, #82ffa1)'}} sx={{ fontSize: "40px" }}/>

如何正确传递 prop ?因为背景:对那个不起作用

9avjhtql

9avjhtql1#

<>
      <svg width={0} height={0}>
        <linearGradient id="linearColors" x1={0} y1={0} x2={1} y2={1}>
          <stop offset={0} stopColor="rgba(78, 91, 135, 1)" />
          <stop offset={1} stopColor="rgba(174, 190, 241, 1)" />
        </linearGradient>
      </svg>
      <AutoModeIcon sx={{ fontSize:40, fill: "url(#linearColors)" }} />
    </>
  )```

Well i founded an solution, not sure if its a correct one

相关问题