css - Material UI v1.0.0 如何重写 Stepper 类来设置图标大小

标签 css reactjs typescript 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>;

    }
}

我确信我必须设置 StepLabel 的样式,但是当我尝试设置只是 coor 到根图标时消失了。

非常感谢您的帮助。

最佳答案

看起来更改步进器图标大小的唯一方法是设置 transform: scale(scaleValue)。检查this codesandbox (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>

关于css - Material UI v1.0.0 如何重写 Stepper 类来设置图标大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47789063/

相关文章:

javascript - 如何在我的计算器中存储结果和查看以前的计算结果?

html - 禁用元素的最佳方法

css - 错误的图标渲染

javascript - 在 componentWillUnmount 中调用时 removeEventListener 不起作用

reactjs - 标题左对齐 React Chart.js V2

reactjs - 如何使用 redux-form 选择器使syncErrors脱离状态

angular - 想要根据 Angular 中的条件加载父组件后访问子组件对象

html - 待办事项列表项文本与后续列表项文本重叠

visual-studio - 带有 Angular2 和 Typescript 的 Visual Studio 2013

javascript - Angular 7 中静态内容的通配符路由