I know, there are plenty of topics like this out there, but unfortunately no approch works for me, where I can set the background color of an ion-item transparent.
sidemenu.component.ts
<ion-menu side="start" menuId="first" contentId="main" class="custom-bg">
<ion-header>
<ion-toolbar>
<ion-title>{{env.appName}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-menu-toggle auto-hide="true">
<ion-item *ngFor="let item of navItems" [routerLink]="item.url" routerDirection="forward">
<ion-icon [name]="item.icon" slot="start"></ion-icon>
<ion-label>{{item.title}}</ion-label>
</ion-item>
</ion-menu-toggle>
</ion-list>
</ion-content>
</ion-menu>
sidemenu.component.scss
ion-toolbar,
ion-content,
ion-item {
--background: transparent;
--color: var(--ion-color-primary-contrast);
}
.custom-bg {
--background: red;
}
The result:
I'm out of ideas, what to try. Notice, that if I set the --background property for the ion-item to a regular color, everything works as expected. To me it looks like there is there is another element with a white background, not just the ion-item.
Note: I can reproduce this strange behaviour via DevTools on the official Ionic 4 docs, where adding a background on that examples ion-content won't shine through if you set an ion-items background to transparent there as well.
Anyone here has an idea, what's going on there?


--ion-color-base: transparent !important;instead - Joel Joseph