angular material mat-select drop-down width

Meng picture Meng · Sep 18, 2018 · Viewed 8.3k times · Source

The current drop-down box has width greater than the the width of the line:
enter image description here

Is there a way to get rid of the extra width?
enter image description here

Here is my current code:

html:

<mat-form-field>
    <mat-select disableOptionCentering placeholder="Choose an option">
      <mat-option [value]="option" *ngFor="let option of my_list">
          {{ option }}
      </mat-option>
    </mat-select>
</mat-form-field>


my_list:

export const my_list: string[] = [ "a", "b", "c", "d"];


style.css:

.mat-select-panel{
    margin-left: 15px;
    margin-top: 28px;
}

Answer

RikG93 picture RikG93 · Sep 18, 2018

Try this and change width:

   <mat-select style="width:10px">