Skip to content

Not able to load mantine css inside iframe #598

Answered by porkopek
318097 asked this question in Q&A
Discussion options

You must be logged in to vote

My case is not an iframe, but the shadow-dom, but I think is the same.
What worked for me was

//creates the shadow dom
const element = document.createElement('div');
const shadowRoot = element.attachShadow({ mode: 'open' });
const mountPoint = document.createElement('div');
const emotionRoot = document.createElement('div');

shadowRoot.appendChild(mountPoint);
shadowRoot.appendChild(emotionRoot);

document.body.appendChild(element);


ReactDOM.render(
  <MantineProvider
    defaultProps={{ Portal: { target: emotionRoot } }} // this is necessary, because Portal renders by default outside of shadow-dom
    emotionOptions={{
      container: emotionRoot, // with this line, emotion renders st…

Replies: 3 comments 29 replies

Comment options

You must be logged in to vote
9 replies
@rtivital
Comment options

@318097
Comment options

@318097
Comment options

@rtivital
Comment options

@ryanseddon
Comment options

Comment options

You must be logged in to vote
14 replies
@hyusetiawan
Comment options

@hjhjdev
Comment options

@laugri
Comment options

@laugri
Comment options

Answer selected by rtivital
Comment options

You must be logged in to vote
6 replies
@Kinbaum
Comment options

@Kinbaum
Comment options

@rtivital
Comment options

@Kinbaum
Comment options

@hyusetiawan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
9 participants