

#
#
#
サンプルコード
class SampleElement extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this.shadowRoot.innerHTML = `
<style>
ul {
width: calc(100% - 50px);
margin: 20px auto;
padding: 10px 10px 10px 25pxpx;
border-radius: 10px;
font-size: 1.5em;
font-weight: bold;
color: #2b2b2b;
background:
linear-gradient(45deg, #83ccd2 25%, transparent 25%, transparent 75%, #83ccd2 75%),
linear-gradient(45deg, #83ccd2 25%, transparent 25%, transparent 75%, #83ccd2 75%);
background-size: 30px 30px;
background-position: 0 0, 15px 15px;
}
</style>
<ul>
<slot name="samplecontent">テキストが入ります</slot>
</ul>
`;
}
}
customElements.define("sample-element", SampleElement);
<sample-element>
<li slot="samplecontent">三毛猫</li>
<li slot="samplecontent">トラ猫</li>
<li slot="samplecontent">白猫</li>
<li slot="samplecontent">黒猫</li>
</sample-element>
<sample-element>
<li slot="samplecontent">鮪</li>
<li slot="samplecontent">鰹</li>
<li slot="samplecontent">鮭</li>
</sample-element>