Change default background color of md-slider of Angular Material

后端 未结 7 633
野的像风
野的像风 2021-02-04 20:06

I am using md-slider of Angular Material version 2.0.0-beta.8

I have selected the indigo-pink theme and imported it in

7条回答
  •  别跟我提以往
    2021-02-04 20:49

    If you want to override the slider's color one at a time, i.e. to apply custom styles to each slider:

    you will need to add classes to your sliders :

           
          
          
    

    Then in your CSS, you can customize each of them as such:

    :host ::ng-deep .average .mat-slider-thumb {
      background-color: #ff3967;
    }
    
    :host ::ng-deep .min .mat-slider-thumb {
      background-color: blue;
    }
    
    :host ::ng-deep .min .mat-slider-thumb-label {
      background-color: blue;
    }
    
    :host ::ng-deep .min .mat-slider-track-fill {
      background-color: blue;
    }
    
    :host ::ng-deep .max .mat-slider-thumb {
      background-color: orange;
    }
    
    :host ::ng-deep .max .mat-slider-thumb-label {
      background-color: orange;
    }
    
    :host ::ng-deep .max .mat-slider-track-fill {
      background-color: orange;
    }
    

    All info about :host and ::ng-deep on the offical Angular documentation for component styles

提交回复
热议问题