JSFiddle - React, Tailwind, and code Playground
HTML
<link
rel="stylesheet"
type="text/css"
href="https://unpkg.com/@kor-ui/kor@1.9.1/kor-styles.css"
/>
<script type="module">
import { LitElement, html } from
'https://unpkg.com/lit@2.1.1/index.js?module';
import 'https://unpkg.com/@kor-ui/kor@1.9.1/components/button/index.js?module';
class KorButtonWrap extends LitElement {
render() {
return html `${
document
.createRange()
.createContextualFragment(`
<kor-button label='${this.label}' color='primary'></kor-button>
`)
}`;
}
}
// Register the Kor button into a custom wrapper element
customElements.define('kor-button-wrap', KorButtonWrap);
// Create the custom wrapper element for the button
let korButtonWrap = document.createElement('kor-button-wrap');
// Define text dynamically after the creation of the wrapped kor button
korButtonWrap.label = 'some text'
// Get div container for appending the element
let container = document.getElementById('container');
// Insert the wrapped kor button into a div container
container.appendChild(korButtonWrap);
</script>
<div id="container"></div>