Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I change the underline color of mat-select in Angular 18?

I want to change the underline color(white) of mat-select if I hover it.

<h4>Basic native select</h4>
<mat-toolbar class="header">
<mat-form-field style="padding-top:20px">
<mat-label style="color:white">Choose an option</mat-label>
<mat-select>
    <mat-option value="option1">Option 1</mat-option>
 </mat-select>
</mat-form-field>
</mat-toolbar>

I have the css like:

.mdc-line-ripple::after {
  transform: scaleX(1) !important;
  opacity: 1 !important;
}

demo: https://stackblitz.com/edit/mpa36f-8pmwyn?file=src%2Fstyles.scss

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use the below CSS, which looks for hover of the form-field, then we set the color which should be the border-bottom-color.

.custom-hover-color:hover {
  .mdc-text-field--filled:not(.mdc-text-field--disabled)
    .mdc-line-ripple::after {
    border-bottom-color: red;
  }
}

Stackblitz Demo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading