Search code examples
angular-materialmat-form-field

Angular Material mat-form-field conditional appearance


This seemed like something simple but for some reason I cant get this to work. So, I want the appearance of the mat-form-field to change based on some condition, for example, if the filed is disabled it should be none and if it is enabled it should be standard.

So for the most simple scenario, how to get this to work:

<mat-form-field  appearance="'true' ? 'standard' : 'none'">
...
</mat-form-field>

Solution

  • This should work:

       <mat-form-field [appearance]="true ? 'outline': 'fill'">
        ...
       </mat-form-field>