I need dynamic colored button in ionic4. This is my code, but not working
<ion-button [style.--background]="colorVarialble">Buttton</ion-button>
You can do by following way
IONIC 4
<ion-button style="--background:red">Red</ion-button> // replace your color
IONIC 3
<button ion-button [ngStyle]="{'background-color':'red'}">Butttons</button> //replace your color
You can use like this:
variables.css
--ion-color-btn: #ef5365;
create class in your home.page.scss
.btncolor {
--background: var(--ion-color-btn);
}
and after add class in your button:
<ion-button shape="round" class="btncolor">
Get Started
</ion-button>
hope it help you :)