Reputation: 41
can any one help me on this: I am already add this in 'global.scss'
.tab-btn-selected {
background: rgb(134,31,194);
color: rgb(134,31,194);
--color-selected: rgb(134,31,194);
}
.tab-btn-selected[aria-selected=true] {
color: #fff; /*your text color */
background: rgb(134,31,194); /* your background color*/
}
but nothing is changed.
Upvotes: 3
Views: 15076
Reputation: 24400
The correct way to do this is to override the Ionic theme variables via the variables.css file:
// variables.css
/* Ionic Variables and Theming. For more info, please see:
http://ionicframework.com/docs/theming/ */
/** Ionic CSS Variables **/
:root {
--ion-tab-bar-color-selected: #F00; /*your desired color */
}
Upvotes: 0
Reputation: 286
tab background you can try below code
ion-tab-bar{
.tab-selected{
// to change background color
background:red;
// to change icon and text color
color:green;
}
}
I hope this will help
Upvotes: 1
Reputation: 1
The following worked for me
ion-tab-button[aria-selected=true] {
background-color: #ddd;
}
Upvotes: 0
Reputation: 378
HTML
<ion-tabs>
<ion-tab-bar slot="bottom">
<ion-tab-button tab="index">
<ion-icon name="list"></ion-icon>
<ion-label>Lessons</ion-label>
</ion-tab-button>
<ion-tab-button class="favorites-button" tab="favorites">
<ion-icon name="heart"></ion-icon>
<ion-label>Favorites</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
SCSS
ion-tab-button.favorites-button {
--color-selected: red;
}
Upvotes: 0
Reputation: 219
In ionic 4 with angular 8 I got it work in web browsers like this (not tested on mobile devices):
in global.css I added:
ion-tab-button {
--ripple-color: var(--ion-color-medium);
--color: var(--ion-color-dark);
--color-selected: var(--ion-color-medium);
}
ion-tab-button.tab-selected {
--background: var(--ion-color-dark) !important;
--color-selected: var(--ion-color-light);
}
Upvotes: 2
Reputation: 71
Just use this in your tabspage SCSS in Ionic 4,
ion-tab-bar{
--color-selected: #000 !important; ( use your favourite color instead of #000 ).
}
Upvotes: 7
Reputation: 390
I am using ionic 4 with stenciljs. My <ion-tab-button/>
had the following class list when unselected:
class="tab-has-icon tab-has-icon-only tab-layout-icon-bottom hydrated"
then when selected:
class="tab-has-icon tab-has-icon-only tab-layout-icon-bottom hydrated tab-selected"
my Component had the following properties:
@Component({
tag: 'app-task',
styleUrl: 'app-task.css'
})
so I added the following to app-task.css and was able to change the font and background color:
.tab-selected{
background: rgb(134,31,194) !important;
color: white !important;
}
Upvotes: 6
Reputation: 77
I did it on variables.scss:
--ion-tabbar-text-color-active: rgb(134,31,194);
Upvotes: 1