【发布时间】:2021-08-23 05:07:52
【问题描述】:
找不到如何更改点的颜色 尝试了 makestyles 的各种变化,包括 点:{ 背景颜色:“#008000!重要” } 但没有任何效果 https://codesandbox.io/s/material-demo-forked-sslwl?file=/demo.js:423-480
【问题讨论】:
标签: reactjs material-ui
找不到如何更改点的颜色 尝试了 makestyles 的各种变化,包括 点:{ 背景颜色:“#008000!重要” } 但没有任何效果 https://codesandbox.io/s/material-demo-forked-sslwl?file=/demo.js:423-480
【问题讨论】:
标签: reactjs material-ui
根据MobileStepper API docs,您需要将属性提供给classes prop 而不是className。更改活动点颜色的示例:
classes={{
dotActive: classes.dot
}}
【讨论】:
下面提到了修复。
const useStyles = makeStyles({
root: {
maxWidth: 400,
flexGrow: 1
},
dot: {
backgroundColor: "#008000"
},
dotActive: {
backgroundColor: "#3f51b5"
}
});
MobileStepper 中的classes prop。<MobileStepper
variant="dots"
steps={6}
position="static"
activeStep={activeStep}
classes={{
root: classes.root, // this will overrides default styles related to MobileStepper root element
dot: classes.dot, // this will overrides default styles related to dot elements
dotActive: classes.dotActive,
}}
nextButton={
<Button size="small" onClick={handleNext} disabled={activeStep === 5}>
Next
{theme.direction === "rtl" ? (
<KeyboardArrowLeft />
) : (
<KeyboardArrowRight />
)}
</Button>
}
backButton={
<Button size="small" onClick={handleBack} disabled={activeStep === 0}>
{theme.direction === "rtl" ? (
<KeyboardArrowRight />
) : (
<KeyboardArrowLeft />
)}
Back
</Button>
}
/>;
注意 - 如果你覆盖了默认的点颜色,那么你也必须覆盖活动的点颜色。
https://codesandbox.io/s/mobilestepper-53cx2?file=/demo.js:343-522
如果您需要进一步的支持,请告诉我。
【讨论】: