Hi all,
i have a general Question about Shadow Elements like the Ionic 4 Components.
I try to set multiple styles to some Ionic 4 Components but for some Components the CSS Variables like --border-bottom is missing, so i am unable to set the Border Bottom Style.
What i did as Workaround, i created these two functions:
async addShadowElementStyle(element: HTMLElement, style: any) {
if (element.shadowRoot === null) {
element.attachShadow({mode: 'open'});
}
const styleElement = document.createElement('style');
styleElement.textContent = style;
await element.shadowRoot.appendChild(styleElement);
}
async addShadowElementsStyle(querySelectorAll: string, style) {
const elements: any = document.querySelectorAll(querySelectorAll);
for (const e of elements) {
this.addShadowElementStyle(e, style);
}
}
and apply my styles with this:
this.helper.addShadowElementsStyle('ion-item', ':host { border-bottom: 1px solid #eee }');
i really do not like this way. But is there a different way to apply custom css to some components?
Best,
Daniel