<div id="swalHTML" style='display: none'> <my-template name="hello"></my-template> </div> let el = document.getElementById('swalHTML'); swal({ html: el.innerHTML });