简体   繁体   English

样式材料 ui React 组件

[英]Styling Material ui React components

I am currently working on these material ui react components and need to customize these components, so I choose this way of styling the component as you can see below我目前正在研究这些 Material ui react 组件,需要自定义这些组件,所以我选择了这种样式化组件的方式,如下所示

.MuiStepIcon-root.MuiStepIcon-completed {
  color: "green"
}

In my app.scss file.在我的 app.scss 文件中。

在此处输入图片说明

I know that there is withStyles using which I have to style my components, as the Ux is complex I find couldn't customize my component using withStyles and I found it difficult to do I that way.我知道我必须使用withStyles来为我的组件设置样式,因为 Ux 很复杂,我发现无法使用withStyles自定义我的组件,而且我发现这样做很困难。

So, Is it ok to customize the component directly using the class names, if no, why?那么,直接使用类名自定义组件可以吗,如果不行,为什么? Please provide me with some help.请给我一些帮助。

It's fine to costumize the components from material-ui using className.可以使用 className 对 material-ui 中的组件进行服装化。 Something that you should keep in mind is that changing a component style with their className(className that material-ui puts in the component) will change all others component's that have the same className.您应该记住的一点是,使用 className(material-ui 在组件中放置的 className)更改组件样式将更改具有相同 className 的所有其他组件。 With that in mind you should try use something to prevent that from happen.考虑到这一点,您应该尝试使用一些东西来防止这种情况发生。

You could pass your className to the component and then use it as the target on css or you can use some css rules that prevent those things, one good example is https://rscss.io/您可以将 className 传递给组件,然后将其用作 css 上的目标,或者您可以使用一些 css 规则来防止这些事情,一个很好的例子是https://rscss.io/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM