简体   繁体   English

我应该将 SCSS 与 material-ui 一起使用还是使用 material-ui 样式?

[英]Should I use SCSS with material-ui or use material-ui styles?

I need an expert view on whether to use material-ui styles OR scss?我需要关于是否使用 material-ui 样式或 scss 的专家意见?

I saw couple of projects shifting to MUI based styles rather than scss , just was going over docs [https://mui.com/system/styles/basics/][1] it say it is deprecated and no longer supported by MUI and is also not supported in react 18.我看到几个项目转向基于 MUI 的样式而不是 scss ,只是在查看文档 [https://mui.com/system/styles/basics/][1] 它说它已被弃用并且不再受 MUI 支持react 18 也不支持。

Also it doesn't support SSR in case of Next.js only thing that is supported by MUI is styled component but that is just like dealing with styled-component library nor it has any speed benefit over scss.此外,在 Next.js 的情况下,它不支持 SSR,只有 MUI 支持的东西是样式化组件,但这就像处理样式化组件库一样,与 scss 相比,它没有任何速度优势。

My question is whether it's wise to use scss with material UI or use material ui styles?我的问题是使用带有材质 UI 的 scss 还是使用材质 ui 样式是否明智? and what are the benefits of using one over other?使用一个比另一个有什么好处?

I wouldn't say that i am an expert but from my experiences working with MUI for 3 years i think you 'll need both.我不会说我是专家,但从我在 MUI 工作 3 年的经验来看,我认为你需要两者。 But make sure you have your own styles and use your scss guidStyles as much as possible , it's easier to inspect and gives you more clear view about the code structure rather than MUI auto generated classes.但是请确保您有自己的样式并尽可能使用您的 scss guidStyles,这样更容易检查并为您提供更清晰的代码结构视图,而不是 MUI 自动生成的类。 In fact sometimes you'll need it eg : if you have to detect some element's width and based on that you have to deal with it and increase some other width + element width , then you can reach it by using MUI makeStyles .事实上,有时你会需要它,例如:如果你必须检测某个元素的宽度,并且基于此你必须处理它并增加一些其他宽度 + 元素宽度,那么你可以使用 MUI makeStyles 来达到它。 So shortly : Make sure you jave your own scss variables, colors, sizes, fonts , etc .. including break points and mixins.所以很快:确保你有自己的 scss 变量、颜色、大小、字体等 .. 包括断点和混合。 But when you need to integrate with MUI feel free to just use it.但是当您需要与 MUI 集成时,请随意使用它。

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

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