Home > Software design >  How add custom class name to ng-select2 container
How add custom class name to ng-select2 container

Time:07-29

I would like add custom class name to ng-select container.

I have select element like below:

 <ng-select
    name="symbolPairsId"
    formControlName="symbolPairsId"
    id="symbolPairsId"
    [items]="setupTags"
    bindLabel="name"
    bindValue="id"
    [closeOnSelect]="true"
    [hideSelected]="true"
    multiple="true" ></ng-select>

and try to add custom class like this:

containerClass="success"

but doesn't work.what is the recommended way of doing this?

Thanks

CodePudding user response:

ng-select does not have property called containerClass, You can override default style by using class selector

component.html

<ng-select ></ng-select>

component.scss

.ng-select.customClass ::ng-deep .ng-select-container  {            
    min-height: 0px;
    border-radius: 0;
}

Reference

  • Related