Toggle color doesnt change

how can i change the color when i pressed the toggle button, i have tried but it doesn’t work with any way…

<ion-item>
<ion-icon name="ios-eye" item-start></ion-icon>
<ion-label> Estado del Equipo:</ion-label>
<ion-toggle [(ngModel)]="userPostData.estado" color="green" *ngIf="checked"></ion-toggle>
<ion-toggle [(ngModel)]="userPostData.estado" color="red" *ngIf="!checked" ></ion-toggle>
</ion-item>

You can only change the color of checked toggles.

[color]="(userPostData.estado)?'green':'red'"
But as rapropos says this will only change the checked color, unless you overwrite the disabled styles or apply a conditional class.
Best regards,
J

Thanks, but how can i overwrite that disabled style?

STFF.

i saw that tutorial, but it used radio-button, i need to use toggle :frowning:

Did you read my comment in that thread, or my earlier one in this thread?

ooh it is works, thanks (y)

how u did it?i want the toggle to change color when its checked and below code is not working

	    <ion-toggle color="green"></ion-toggle>

Can try this

HTML:

<ion-item id="bg">
    <ion-label>TOGGLE COLOR</ion-label>
    <ion-toggle color="dark"></ion-toggle>
</ion-item>

CSS:

#bg{
    background: rgb(54, 189, 194);
}