<main>
<our-button>버튼 1</our-button>
<our-button>버튼 2</our-button>
<our-button>버튼 3</our-button>
</main>
<template id="our-button">
<style>
:host {
--button-color: #ffffff;
--button-bg-color: #0d6efd;
--button-hover-bg-color: #025ce2;
}
button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
margin: 0;
padding: 0.5rem 1rem;
font-family: "Noto Sans KR", sans-serif;
font-size: 1rem;
font-weight: 400;
text-align: center;
text-decoration: none;
display: inline-block;
width: auto;
border: none;
border-radius: 4px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
cursor: pointer;
transition: 0.5s;
background: var(--button-bg-color);
color: var(--button-color);
&:active,
&:hover,
&:focus {
background: var(--button-hover-bg-color);
outline: 0;
}
&:disabled {
opacity: 0.5;
}
}
</style>
<button>
<slot/>
</button>
</template>
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR&display=swap");
main {
display: flex;
flex-wrap: wrap;
gap: 32px;
justify-content: space-evenly;
align-items: center;
min-height: 100dvh;
}
class OurButton extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
const template = document.getElementById("our-button");
const clone = template.content.cloneNode(true);
this.shadowRoot.appendChild(clone);
}
}
customElements.define('our-button', OurButton);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.