Source Code:
(back to article)
Submit
Result:
Report an issue
<div> <script> class MyStyledComponent extends HTMLElement { constructor() { super(); let shadow = this.attachShadow({ mode: 'open' }); shadow.innerHTML = ` <style> p { font-size: 20px; color: green; } </style> <p>This is my styled component!</p> `; } } customElements.define('my-styled-component', MyStyledComponent); </script> <my-styled-component></my-styled-component> </div>