I am applying table styles inside the shadowDOM custom element template, inside the slot, it's not accepting the table th and td CSS.
class Table extends HTMLElement {
constructor() {
super();
// console.log("this accordion -> ", this)
setTimeout(() => {
const template = document.createElement('template');
template.innerHTML = `
<style>
::slotted(table) {
color: red;
width: 100%;
}
::slotted(table tr th),
::slotted(table tr td) {
text-align: left;
padding: 10px 0;
}
</style>
<slot></slot>
`;
const shadowDOM = this.attachShadow({
mode: 'open'
});
shadowDOM.appendChild(template.content.cloneNode(true));
}, 0);
}
}
customElements.define('t-table', Table);
<t-table>
<table>
<tr>
<th>Sl No.</th>
<th>Name</th>
</tr>
<tr>
<td>1</td>
<td>Name</td>
</tr>
</table>
</t-table>
how to apply CSS for the above scenario?