[FIXED] How to set onLabel and offLabel for primeng p-inputSwitch

Issue

I need to add "Yes" for On state and "No" for off state. Is there is any option available for doing this?

<p-inputSwitch [(ngModel)]="checked" name="first-chk" (onChange)="myFunction())"> </p-inputSwitch>

Solution

Please update the stylesheet for showing yes

.p-inputswitch.p-inputswitch-checked .p-inputswitch-slider:after {
   content: "Yes" !important;
   position: absolute;
   top: 0 !important;
   left: 0 !important;
   right: 0 !important;
   border: 0 !important;
   height: 100%;
   display: flex;
   align-items: center;
  font-size: 15px !important;
   margin: 0px 8px !important;
  color: #fff !important;
  -webkit-animation: barshine 0.5s 0.1s forwards;
  animation: barshine 0.5s 0.1s forwards;
}

Answered By – Anandu Krishna

Answer Checked By – Mildred Charles (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published