Style applied to host element
.host {
padding: 0.5rem 1rem;
box-shadow: 0 0 0.3rem rgba(0, 0, 0, 0.25);
}
<x-nametag class="host"></x-nametag>
.host {
padding: 0.5rem 1rem;
box-shadow: 0 0 0.3rem rgba(0, 0, 0, 0.25);
}
<x-nametag class="host"></x-nametag>
We can set custom styles for the shadow DOM with a <style>
tag inside the shadow root:
<x-fancy-nametag>
<span slot="icon">😱</span>
<span slot="name">Ladybenko</span>
</x-fancy-nametag>
Note em
inherited properties go through the shadow DOM:
<x-fancy-nametag style="font-size:2em; color: orangered">
<span slot="icon">🦊</span>
<span slot="name">Firefox</span>
</x-fancy-nametag>
This can be seen in the Inspector (look for Inherited from x-user-styled
in the Rules panel):
Shadow DOM encapsulates styles so: