<mesh-card id="card-123" hx-swap-oob="true"> <template shadowrootmode="open"> <link rel="stylesheet" href="/static/css/components/card.css" /> <div class="card"> <div class="card-header"> <h3>Updated Card Title</h3> </div> <div class="card-content"> Updated card description here. </div> <div class="actions"> <button type="button">Edit</button> </div> </div> </template> </mesh-card> class MeshCard extends HTMLElement { connectedCallback() { if (!this.shadowRoot) { const tmpl = this.querySelector('template[shadowrootmode="open"]'); if (tmpl) { this.attachShadow({mode: 'open'}) .appendChild(tmpl.content.cloneNode(true)); } } } } customElements.define('mesh-card', MeshCard);