I'm trying to apply some styles on the shadow DOM. I have this example:
const existingElement = document.getElementById("foo");
const shadow = existingElement.attachShadow({ mode: "open" });
const message = document.createElement("p");
message.setAttribute("class", "text");
message.textContent = "Hello World!";
shadow.appendChild(message);
#foo::shadow .text{
color: blue; //not working
}
<div id="foo"></div>In the snippet I'm generating a <p class="text">Hello World!</p> in the shadow root inside that <div id="foo"></div>
I need to apply styles to that class text but as it is inside the shadow DOM I can't apply any styles directly. I have tried with ::shadow, ::ng-deep, ::content but no results yet. Any idea?
Comments
Post a Comment