首页 > 解决方案 > 更改样式(颜色)线性进度条/材质 UI/Reactjs

问题描述

 <LinearProgress style={{barColorPrimary: "red"}}" value={Number(campanha.Percentual)} />

如何更改栏的 barColorPrimary?我需要使用代码中的样式。

标签: javascripthtmlreactjsmaterial-ui

解决方案


我喜欢使用 withStyles() 高阶组件来注入自定义样式。

在此处查看 LinearProgress 的示例:https ://codesandbox.io/s/material-demo-forked-kwvb1?file=/demo.tsx (我们为条形颜色覆盖 barColorPrimary,为背景覆盖 colorPrimary)。

有关在 Material UI 中自定义组件的更多信息,请参见:https ://material-ui.com/customization/components/


推荐阅读