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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to change style from being added to the HTML DOC head, instead append it to right before the react app "Root" in a dom shadow mode #21230

Closed
1 task done
mhmo91 opened this issue May 28, 2020 · 3 comments
Labels
status: waiting for author Issue with insufficient information

Comments

@mhmo91
Copy link

mhmo91 commented May 28, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 馃挕

MUI styles are bing added globally to the HTML Doc Top level head... that's fine if your app is a standalone application, but imagine you wanna ship your react app built with MUI as a widget to be used inside another website (potentially also using MUI), even when we wrap the app inside a custom element, MUI always appends the style tag to the top level head which ends up breaking the style of the hosting website.

Motivation 馃敠

Being able to build your app as a widget and ship it to million of the website with a single script where your app lives inside a shadow Dom element is a demand that will only keep growing.

The only alternative at the moment would be to embed the widget as an iframe which is not a perfect fit in many cases specially when we can leverage the browser's support for custom html element

@eps1lon
Copy link
Member

eps1lon commented May 28, 2020

MUI always appends the style tag to the top level head which ends up breaking the style of the hosting website.

Our styles are scoped to the components. They shouldn't affect global styles unless you use CssBaseline. We have a scoped variant for that as well with ScopedCssBaseline.

Could you provide a reproduction that illustrates the concrete issue you have?
This codesandbox.io template is a good starting point.

For shadow DOM support see #17473

@eps1lon eps1lon added the status: waiting for author Issue with insufficient information label May 28, 2020
@oliviertassinari
Copy link
Member

@mhmo91 Also, please refer to this https://material-ui.com/styles/advanced/#insertionpoint option to move the styles inside the shadow dom. You could ask @NMinhNguyen for more details on how to proceed. I believe he has experience with doing it.

@oliviertassinari oliviertassinari added the package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. label May 28, 2020
@mhmo91
Copy link
Author

mhmo91 commented May 28, 2020

@oliviertassinari Thanks a Million!

Just an update though for whoever might land here, don't try the insertion point mechanism on https://codesandbox.io/ as it won't work

@oliviertassinari oliviertassinari removed the package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. label Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

3 participants