I am trying in different way which I followed link(How to set background color IONIC 4) for header background color and tried as per ionic 2 and ionic 3 as well:
I am able to make background color for ion-content, but background color is not coming for header.
Code:
<ion-header> <ion-toolbar style="background-color: red"> <ion-title>Login</ion-title> </ion-toolbar> </ion-header>
Please need your support.
Change the color or image of the header Go to the Design tab. Click Customize to expand the set of choices for customizing your theme. Click Header Image to choose an image to be the background of the header. Click Header background to choose a color for the header section.
Styling the Ionic 5 Toolbar ( ion-toolbar ) $toolbar-background: #123456; $toolbar-border-color: #123456; $toolbar-text-color: #123456; $toolbar-active-color: #123456; $toolbar-inactive-color: #123456; Just put them in the variables. scss file and change their values to your desired colors.
To fix this you need to add a 'has-header' or a 'has-subheader' class to the ion-content tags of your screens. Open one of your HTML files from www/templates and add the has-subheader class to the ion-content. If you only use header in your app, you will need to add the has-header class instead.
It seems like the ion-header acts more as a container for an inner ionic component (like an ion-toolbar). I looked over the Ionic v4 ion-toolbar documentation. This component has many custom css custom properties, including --background, that can be customized. This may be what you're looking for.
Assuming you used the CLI to create a 'login' page component, you can add a new css class definition to the login.scss file:
.new-background-color{ --background: #54d61c; }
And then refer to it in your login.page.html file:
<ion-header> <ion-toolbar class="new-background-color"> <ion-title>Login</ion-title> </ion-toolbar> </ion-header>
I've used the following code snippet to change color of header:
<ion-header> <ion-toolbar color="primary"> <ion-title>Login</ion-title> </ion-toolbar> </ion-header>
Instead of primary color, you can use any custom color from variables.scss file.
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