3

I am using ng-select (https://ng-select.github.io/ng-select#/data-sources) library in my angular project to display a drop down as follows:

<ng-select
  [items]="flattenedSelectList"
  bindLabel="displayName"
  placeholder="Select specialty"
  notFoundText="No results found. Please try a different search criteria."
  bindValue="id"
  groupBy="type"
  [(ngModel)]="selectedSpecialtyId">
</ng-select>

I want to style the group header and also the items inside each group? How can I do it?

I used the following in my .scss file but it does not seem to apply the changes. ng-optgroup for group header and ng-option-label for item.

.ng-optgroup {
  font-weight: bold;
  color: #dbe8ef;
}

.ng-option-label{
  color: red;
}
aUXcoder
  • 1,048
  • 1
  • 20
  • 32
Karu
  • 935
  • 2
  • 13
  • 32

1 Answers1

5

Use this style and add in core file style.css :

.ng-dropdown-panel .ng-dropdown-panel-items .ng-optgroup{
  font-weight: bold;
  color: #dbe8ef;
}
.ng-option-label{
  color: red;
}

Stackblitz : https://stackblitz.com/edit/angular-ztb1ug

Avinash Dalvi
  • 8,551
  • 7
  • 27
  • 53