Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of primeng input-switch

Tags:

html

css

primeng

I have the following p-inputSwitch.

<p-inputSwitch class="ml-1 mr-1 align-middle"
               (onChange)="setDefaultValues($event)"
               [ngModel]="defaultValuesToggle">
</p-inputSwitch>
           

Is there a way to change the color from blue when selected? I have tried the following, but nothing changes the color:

.p-inputswitch {
    background: red !important;
}
.p-inputswitch .p-inputswitch-slider {
  background: red !important;
}
like image 883
Pippa97 Avatar asked Oct 25 '25 01:10

Pippa97


1 Answers

You need to add the "selected" state to the selector by adding the class p-inputswitch-checked to .p-inputswitch and also add ::ng-deep infront of the selector to penetrate View Encapsulation:

::ng-deep .p-inputswitch.p-inputswitch-checked .p-inputswitch-slider {
  background: purple;
}
like image 138
Shai Avatar answered Oct 26 '25 15:10

Shai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!