Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the color of mat-slider

I'm currently learning angular and I have come across an issue that I'm sure is very easily solved but I have been unable to fins an answer to.

I have the following code in my project:

<mat-slider step="10" [value]="80" thumbLabel (change)="updateValue($event)" class="selector"></mat-slider>

At the minute, the selector line and thumb appears as yellow which seems to be the default color.

Can anyone advise what I need to do to change the color of the slider and thumb?

I have tried the following in the scss file and can't get any changes to come through:

.mat-slider-thumb {
    border-color: red;
    background-color: blue;
}

.mat-slider {
    border-color: red;
    background-color: green;
}

The only thing that works in the above is the background color change to green which changes the full element background color.

like image 518
nimgwfc Avatar asked Oct 20 '25 18:10

nimgwfc


1 Answers

This is what I needed to make it all red it turns out, in the themes.scss file

.mat-accent .mat-slider-track-fill {
        background-color: red !important;
    }

.mat-slider-thumb-label {
        background-color: red !important;

    }

.mat-slider-thumb {
        background-color: red !important;
    }
like image 150
nimgwfc Avatar answered Oct 22 '25 10:10

nimgwfc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!