0

I an Angular 8 project with Angular Material, I have a form and in it I need to add a select box that have this style:

design

Note the label "Select an option" style how stands in the middle of the line.

The html code:

<mat-form-field>
  <mat-label> Select an option</mat-label>
  <mat-select>
    <mat-option *ngFor="let type of types" [value]="type">{{type}}</mat-option>
  </mat-select>
</mat-form-field>

The ts code:

types: string[] = [
    'Charmander', 'Bulbasaur', 'Squirtle'
  ];

I can't find anywhere in the documentation how to make the "Select an option" to stay in the middle of the line. Here is the stackblitz link

Can someone help me please?

1 Answer 1

2

set appearance to outline like below:

<mat-form-field appearance="outline">
    <mat-label> Select an option</mat-label>
    <mat-select>
        <mat-option *ngFor="let type of types" [value]="type">{{type}}</mat-option>
    </mat-select>
</mat-form-field>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.