Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Remove style duplication #28087

Merged
merged 1 commit into from
Sep 2, 2021

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Sep 1, 2021

I think that we should be careful with the sx prop. It seems that we can easily overuse it. In #27956 I saw similar patterns where we were using styled(), then overriding the same property in sx.

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Sep 1, 2021
@mui-pr-bot
Copy link

mui-pr-bot commented Sep 1, 2021

No bundle size changes (experimental)

Generated by 🚫 dangerJS against d02f193

@eps1lon
Copy link
Member

eps1lon commented Sep 1, 2021

I think that we should be careful with the sx prop. It seems that we can easily overuse it.

While & .someClass has the downside of affecting everything in the component tree. This is one of the problems CSS-In-JS solved by narrowing the scope of the styles. You're now expanding the scope again.

@oliviertassinari
Copy link
Member Author

@eps1lon I guess it's a tradeoff.

I think that the advantage of the current approach is that we have a big chunk of the advantage of the scoped CSS. We scope at the file component level, not at the project level while also retaining the simplicity in how the override is written. We don't create yet another component. I think that it's more or less the tradeoff CSS modules have and that de had with the makeStyles API. I personally also like that the default behavior. If we are not aware of this CSS override, the default is for it to apply to all the svg icons. There is no need to remember to use the right sx value or class names or component name. It's close to how a ThemeProvider or a CSS variables would behave.

@oliviertassinari oliviertassinari merged commit 165383c into mui:next Sep 2, 2021
@oliviertassinari oliviertassinari deleted the no-style-duplication branch September 2, 2021 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants