adding style to mat-option of mat-autocomplete

  angular, angular-material, css, html, sass

I have this HTML code here

<div style="width: 150px">
  <form class="example-form">
  <mat-form-field class="example-full-width">
    <input type="text" placeholder="Assignee" aria-label="Assignee" matInput [formControl]="myControl" [matAutocomplete]="auto">
    <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
      <mat-option *ngFor="let option of filteredOptions | async" [value]="option">
        {{option.name}}
      </mat-option>
    </mat-autocomplete>
  </mat-form-field>
</form>
</div>

The default behaviour of mat-option is using


  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis

  1. I want to break the long sentence into next line rather than using ... . The styling wont work 🙁
  2. I also need to override the font which I tried also using below code, but it wont override
mat-option {
    font-family: "Times New Roman", Times, serif; // does not work
  }

styling here

Please help.

Source: Angular Material Quesions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.