I am using basic mat-select component in my project.
<mat-form-field>
<mat-select placeholder="Favorite food">
<mat-option *ngFor="let food of foods" [value]="food.value">
{{food.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
how can i remove the underline,I have tried this answer too still no result.
to the component style's sheet or the styles. scss of your angular app. Caution this will remove every arrow in mat-select. if you want to remove arrow for a few ones just add a class to mat-form-field and nest your class in the scss file.
The compareWith just literally compares objects by some given values and the checkboxes get selected, if it returns true . In my code, I decided to go with the ng-Model binding but it works with formControl as well: <mat-form-field>
You can do this:
::ng-deep .mat-form-field-underline { display: none; }
StackBlitz
You can also use the appearance
property on the <form-field>
. Setting appearance="none"
will remove the underline without any css hack. And you can also get rid of ::ng-deep
which is not recommended.
So your code will be like this.
<mat-form-field appearance="none">
<mat-select placeholder="Favorite food">
<mat-option *ngFor="let food of foods" [value]="food.value">
{{food.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
For more information on appearance, you can check here. https://material.angular.io/components/form-field/overview#form-field-appearance-variants
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With