Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How add custom class name to ng-select2 container

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

containerClass="success"

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

Thanks

>Solution :

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

component.html

<ng-select class="customClass"></ng-select>

component.scss

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

Reference

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading