Iva*_*tan 2 css typescript reactjs material-ui
我现在正在迁移到新版本的Material UI。我不得不说,我有点困惑如何重写类。
我需要使用带有替代标签的Stepper,它对我有用,我能够覆盖根类以设置透明背景。
但是我需要将步骤图标大小设置为42px,但我不成功。
我的代码看起来:
const styles = {
root: {
backgroundColor: "rgba(255, 0, 0, 0)",
}
};
const MyStepper = (props) => {
return (
<Stepper
activeStep={props.activeStep}
alternativeLabel
classes={{
root: props.classes.root,
}}
>
{props.children}
</Stepper>
);
}
const StyledStepper = withStyles(styles)(MyStepper);
export default class CheckoutStepper extends React.PureComponent<ICheckoutStepperProps, {}> {
public render() {
return <div >
<StyledStepper
activeStep={this.props.step}
>
<Step>
<StepLabel>
{stepTable[0].label}
</StepLabel>
</Step>
<Step>
<StepLabel>
{stepTable[1].label}
</StepLabel>
</Step>
<Step >
<StepLabel>{stepTable[2].label}</StepLabel>
</Step>
<Step>
<StepLabel>{stepTable[3].label}</StepLabel>
</Step>
</StyledStepper>
</div>;
}
}
Run Code Online (Sandbox Code Playgroud)
我确定我必须设置StepLabel的样式,但是当我尝试设置根目录图标时,就会消失。
非常感谢您的帮助。
看来是设置步进图标大小的唯一方法transform: scale(scaleValue)。选中此代码和框(demo.js文件)。请注意以下代码:
const styles = theme => ({
root: {
width: '90%',
},
backButton: {
marginRight: theme.spacing.unit,
},
instructions: {
marginTop: theme.spacing.unit,
marginBottom: theme.spacing.unit,
},
iconContainer: { // define styles for icon container
transform: 'scale(2)',
}
});
...
<Stepper activeStep={activeStep} alternativeLabel>
{steps.map((label, index) => {
return (
<Step key={label}>
<StepLabel classes={{ // apply this style
iconContainer: classes.iconContainer
}}>{label}</StepLabel>
</Step>
);
})}
</Stepper>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1827 次 |
| 最近记录: |