mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.64k stars 32.22k forks source link

[docs] How to build a third party library? #17146

Closed charlax closed 5 years ago

charlax commented 5 years ago

Current Behavior 😯

material-ui-banner uses @material-ui/styles for its style solution, requiring the installation of another ThemeProvider. See https://github.com/alexplumb/material-ui-banner/issues/5

There is a confusion as to whether libraries that use material-ui components should import from @material-ui/core/styles or @material-ui/styles. I believe it should import from @material-ui/core/styles to avoid having to install the theme twice (as material-ui-pickers does).

https://material-ui.com/getting-started/faq/#i-have-several-instances-of-styles-on-the-page seems to say the same thing but could be more assertive in laying out the right solution for libraries.

Expected Behavior 🤔

Start a new documentation page to provide best practices for libraries extending material-ui.

Clarify which of @material-ui/core/styles or @material-ui/styles should be used by libraries.

oliviertassinari commented 5 years ago

Thanks for this issue. I think that third party libraries should be using @material-ui/core as a peer dependency and import from core/styles. Basically, use the same stack than the core components. @material-ui/styles started has an effort to isolate the components to the styling solution. I don't think that it was a successful enterprise. We have created friction (which one should be used?), it hasn't gained traction outside of Material-UI, it weaken react-jss, it hasn't made switching between different style engines possible, at least, not yet.

oliviertassinari commented 5 years ago

Start a new documentation page to provide best practices for libraries extending material-ui.

@charlax Yes, I think that it would help! I like what Gatsby has: https://www.gatsbyjs.org/docs/creating-plugins/. What do you think of a new guide under: /guides/extending-material-ui?

charlax commented 5 years ago

Yep, that'd be great!

oliviertassinari commented 5 years ago

I'm closing. I think the people should follow the other existing projects, lead by examples. Also, I have renamed the issue so third party authors can better find it.