ConfirmDialog: is not loading inside a Shadow DOM
Describe the bug
I have the code as below with file name testView.tsx `import * as React from "react"; import * as ReactDOM from "react-dom";
import "./theme/resourceapp/theme.css"; import "primereact/resources/primereact.min.css"; import "primeicons/primeicons.css"; import {TuningBucket} from "./components/tuning/TuningBucket"; import {TestView} from "./components/TestView";
const root = document.getElementById("test-view") as HTMLElement; const shadowRoot = root.attachShadow({ mode: "open" });
const reactRoot = document.createElement("div"); shadowRoot.appendChild(reactRoot);
const event = new Event("react-ready"); document.dispatchEvent(event);
ReactDOM.render(
And TestView.tsx file code `import * as React from "react"; import {useState} from "react"; import {Button} from "primereact/button"; import {ConfirmDialog} from "primereact/confirmdialog";
export const TestView = () => {
const [visible, setVisible] = useState
- From the image the one which is rounded with black is the output for the ConfirmDialog component
- Rounded with Green is the Shadow Dom code which includes all the Primereact stylings
- And Rounded with Red is the code of ConfirmDialog at run time loading out side of ShadowDom

Reproducer
No response
PrimeReact version
^8.1.1
React version
17.x
Language
TypeScript
Build / Runtime
Create React App (CRA)
Browser(s)
No response
Steps to reproduce the behavior
No response
Expected behavior
No response
Need you guys help to fix such that ConfirmDialog code should come inside of Shadow dom code So that the styling of the ConfirmDialog code applied correctly.
Can you create a reproducer so we can see what you are talking about and debug it?
Screenshots don't help.
A Code Sanbox reproducer would help.
Hi,
Unfortunately, I couldn't replicate this issue. Please try; https://codesandbox.io/s/primereact-test-forked-uxr48m?file=/src/index.js
If the problem persists, please reopen this issue. For now, closed. Thanks a lot for your understanding!
Best Regards,
@mertsincan Your codesandbox example does exactly what @kartheekgadduru describes :) Look at your confirm an delete buttons. The are not styled because the are in the shadow dom. Now your Dialog is placed outside the shadow DOM (in the normal DOM tree) so it is styled.
But this is how I solved my normal Dialog in the Shadow Dom <Dialog appendTo={context.shadowRoot} />
Where my context knows about the shadowRoot and the entire App waits until it is available.
This probably will work for @kartheekgadduru and the ConfirmDialog as well.
I tried this <ConfirmDialog appendTo={context.shadowRoot}/> but that does indeed not work.
The Dialog component works though. See both in action here https://codesandbox.io/s/5wou0t
At this moment I do not know how to get all the primereact css in the Shadow DOM of codesandbox so just one class there, but you should get the point.
PS I really really like primereact so thank you all.
HI @melloware and @rogiermulders Please find my codesandbox url (https://codesandbox.io/s/vigorous-framework-ngnggk) for the code in my project in which I am testing the ConfirmDialog should render inside the shadowRoot and should apply all the styles of prime react for the ConfirmDialog component
import 'primeicons/primeicons.css';
import 'primereact/resources/themes/lara-light-indigo/theme.css';
import 'primereact/resources/primereact.css';
but in my code I supposed to have anchored tag similar to after login button from codesandbox url
<a href="./testView.do">
testView
</a>
Whatever the code which have provided from the codesandbox url is working in my local. I think this info is helpful to address my issue related to ConfrimDialog primereact component please let me know if you need some more information which is needed for this issue
Fixed with: https://github.com/primefaces/primereact/pull/5566