Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change css when ng-select is used?

Tags:

css

angular

I am currently using ng-select for drop down like

<ng-select [items]="tests"
           (data)="signalChanged($event)"
           [active]="test"
           id="test)">
</ng-select>

I want to change the back ground color of the active element in the drop down list. How do I access it's css?

like image 622
code1 Avatar asked Jul 11 '17 17:07

code1


People also ask

Is ng deep deprecated?

Both APIs ::ng-deep and /deep/ are deprecated and will eventually be removed in the future.

How do I remove the clear icon from Ng-select?

In your stylesheet add display: none; to the . ng-clear-wrapper selector.

How do I make ng-Select Disabled?

The best way to do this is by using reactive form control. [readonly] boolean false no Set ng-select as readonly. Mostly used with reactive forms. adding [disabled]="true" did not work for me But setting [readOnly] to true did.


2 Answers

You can customize as per official documentation. To find exact class you need to override, do inspect and identify the class.

<ng-select class="custom"></ng-select>
.ng-select.custom {
    border:0px;
    min-height: 0px;
    border-radius: 0;
}
.ng-select.custom .ng-select-container  {            
    min-height: 0px;
    border-radius: 0;
}

If you are using ViewEncapsulation, your should use special ::ng-deep selector which will prevent scoping for nested selectors.

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

https://www.npmjs.com/package/@ng-select/ng-select#custom-styles has more details around the same.

like image 142
Chetan Laddha Avatar answered Sep 22 '22 17:09

Chetan Laddha


I suggest you override the styles as mentioned here. In addition to that try setting the Encapsulation for the component.

encapsulation: ViewEncapsulation.None
like image 37
James Poulose Avatar answered Sep 22 '22 17:09

James Poulose