I use ionic4 now. And my client and his designer give a picture like below.
It need to make tabs has transparent but I don't know how to set. I have try to add in variables.scss
but the transparent is no working. If only change color is work.
.ion-color-tabstrans {
--ion-color-base: rgba(100,100,100,0.1);;
}
From the tab-bar
docs seems like you can change the background by using the --background
CSS property like this:
HTML
<ion-tabs>
<!-- Tab bar -->
<ion-tab-bar class="my-custom-tab-bar" slot="bottom">
<ion-tab-button tab="account">
<ion-icon name="person"></ion-icon>
</ion-tab-button>
<ion-tab-button tab="contact">
<ion-icon name="call"></ion-icon>
</ion-tab-button>
<ion-tab-button tab="settings">
<ion-icon name="settings"></ion-icon>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
SCSS
ion-tab-bar.my-custom-tab-bar {
--background: rgba(100,100,100,0.1);
}
EDIT
You'd probably need to change the background of the ion-tab-button as well
ion-tab-bar.my-custom-tab-bar ion-tab-button {
--background: transparent;
}
EDIT II
The answer above is correct, but is missing something that makes everything not to work as expected. The problem is that the ion-tabs
element is placed outside of the element that represents the content. What you need based on your question is to place the tabs above the content instead.
One way to do that is by setting the positioning of the ion-tabs
to be absolute, like this:
HTML
<ion-tabs>
<!-- I've added a my-custom-tab-bar class to the ion-tab-bar element -->
<ion-tab-bar class="my-custom-tab-bar">
<!-- ... -->
</ion-tab-bar>
</ion-tabs>
SCSS
ion-tab-bar.my-custom-tab-bar {
position: absolute;
bottom: 0;
width: 100%;
--background: rgba(255,255,255,0.8);
ion-tab-button {
--background: transparent;
}
}
That produces this result:
Notes
margin-bottom
to the content of each page that is used as a tab.safe-area
at the bottom like the iPhone X.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With