Angular 5 ng-select

Dev Db picture Dev Db · May 2, 2018 · Viewed 19.8k times · Source

I am using ng-select component from https://github.com/ng-select/ng-select . However the content of the dropdown is in some cases too long. The string in the dropdown will be shortened with ... Is it possible to make the dropdown bigger than the input width, according to the length of the content? Possibly with CSS styling (custom).

<div layout="row">
    <label>Your first ng-select</label>
    <ng-select class="custom" [items]="cities"
               bindLabel="name"
               placeholder="Select city"
               [(ngModel)]="selectedCity">
    </ng-select>

    <label>Your first ng-select</label>
    <ng-select class="custom" [items]="cities"
               bindLabel="name"
               placeholder="Select city"
               [(ngModel)]="selectedCity">
    </ng-select>
</div

Answer

Stefan picture Stefan · May 2, 2018

In the CSS/SCSS (what you are using for styling) set

.ng-dropdown-panel {
    min-width: 100%;
}

However it doesn't look that good...

enter image description here

Alternative:

Remove white-space: nowrap; from .ng-dropdown-panel .ng-dropdown-panel-items .ng-option then it breaks into multiple lines.

enter image description here