Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 5 ng-select

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
like image 505
Dev Db Avatar asked Dec 19 '25 09:12

Dev Db


1 Answers

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

like image 115
Stefan Avatar answered Dec 22 '25 02:12

Stefan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!