2

I'm using PrimeNG selectButton component. https://www.primefaces.org/primeng/showcase/#/selectbutton. I can't find a way to change the blue background color of the selected button, to a different one.

enter image description here

This is my html code

<p-selectButton [options]="brands" multiple="multiple" >
                    <ng-template let-car let-i="index" pTemplate="item">
                        <div class="brand-image-container">
                            <img id="{{car.value}}" src="./assets/images/png/brand-logos//{{car.label}}.png">
                        </div>
                    </ng-template>
                </p-selectButton>

And this is my scss:

::ng-deep {
  .ui-selectbutton .ui-button.ui-state-default {
    border-radius: 20px;
    border: solid 0 transparent;
    background-color: transparent;
    margin-right: 10px;
  }
}

::ng-deep {
   .ui-selectbutton .ui-button.ui-state-active {
        background-color: red;
    }
}
::ng-deep {
       .ui-selectbutton .ui-button.ui-state-highlight {
            background-color: green;
        }
    }

Only the default state is working.

Any help on why highlight and active states are not working ?

M1rwen
  • 1,742
  • 3
  • 16
  • 19

2 Answers2

2

Try with these classes:

::ng-deep {
  .p-selectbutton .p-button.p-highlight {
    background: red;
    background-color: red;
  }

  .p-selectbutton .p-button.p-highlight:hover {
    background: green;
  }
}

See StackBlitz

Antikhippe
  • 6,316
  • 2
  • 28
  • 43
0

Hi i used to meet bug like you, it may be in your project have a different class when active. Example: In stackBlitz it will ->

    ::ng-deep .p-selectbutton .p-button.p-highlight {
    color: #007ad9 !important;
    font-weight: 700;
  }

But in my project it will ->

    ::ng-deep .ui-selectbutton .ui-button.ui-state-active {
    color: #007ad9 !important;
    font-weight: 700;
  }

It works fine for me you can try it. Thanks