Mantine and shadow dom #5224
Unanswered
dexter4life
asked this question in
Q&A
Replies: 2 comments 4 replies
-
You can change css variables selector with https://mantine.dev/theming/mantine-provider/#cssvariablesselector |
Beta Was this translation helpful? Give feedback.
4 replies
-
I think I got this working. In addition to setting class MyWebComponent extends HTMLElement {
private readonly root: HTMLElement;
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: "open" });
const cssUrl = new URL('./styles.css', import.meta.url).href;
const cssLink = document.createElement('link');
cssLink.setAttribute('rel', 'stylesheet');
cssLink.setAttribute('href', cssUrl);
shadowRoot.appendChild(cssLink);
this.root = document.createElement('div');
this.root.setAttribute('id', 'root');
shadowRoot.appendChild(this.root);
}
connectedCallback() {
const theme = createTheme({
components: {
Portal: {
defaultProps: {
target: this.root
},
}
}
});
ReactDOM.createRoot(this.root).render(
<MantineProvider
cssVariablesSelector="#root"
getRootElement={() => this.root}
theme={theme}
>
<ModalsProvider>
<App />
</ModalsProvider>
</MantineProvider>,
);
}
}
customElements.define("my-component", MyWebComponent); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to setup a shadow dom and render a mantine component within this shadow dom. After loading core css into the shadow dom, using <style>...</style> it appears all the variables except those in the :root isn't working.
Beta Was this translation helpful? Give feedback.
All reactions