ng select style group headers and items

安稳与你 提交于 2021-01-28 14:20:29

问题


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;
}

回答1:


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



来源:https://stackoverflow.com/questions/62782237/ng-select-style-group-headers-and-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!