Template Slot Shadow DOM Component
Define a reusable component using template and slot elements inside a shadow DOM root for encapsulation.
Code
<template id="card-template">
<style>
.card { border: 1px solid #ccc; border-radius: 8px; padding: 16px; }
h3 { margin: 0 0 8px; }
</style>
<div class="card">
<h3><slot name="title">Default Title</slot></h3>
<p><slot>Default content</slot></p>
</div>
</template>
<my-card>
<span slot="title">Custom Title</span>
Custom content here
</my-card>Report a problem with this exampleOpens a pre-filled issue on GitHub.