Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I display thumb label all the time for material slider?

I want to let thumb label to display all the time no matter it is focused or not. When I click on the slider it shows label like this.

enter image description here

But as soon as it is unfocused, the label is gone.

enter image description here

How can I get the label stay ?

like image 335
sally Avatar asked Sep 23 '19 07:09

sally


2 Answers

Angular Material doesn't provide this functionality by default, but you can handle this by adding following css in your global css file:

.mat-slider-thumb-label {
    transform: rotate(45deg) !important;
    border-radius: 50% 50% 0 !important;
  }

.mat-slider-thumb {
    transform: scale(0) !important;
}

.mat-slider-thumb-label-text {
    opacity: 1 !important;
}

Working demo on stackblitz

like image 147
Mustahsan Avatar answered Oct 24 '22 09:10

Mustahsan


The accepted answer didn't work consistently for me until I wrapped it in ng-deep

::ng-deep {
  .mat-slider-thumb-label {
    transform: rotate(45deg) !important;
    border-radius: 50% 50% 0 !important;
  }  
  .mat-slider-thumb {
    transform: scale(0) !important;
  }  
  .mat-slider-thumb-label-text {
    opacity: 1 !important;
  }
}

This solution came from willshowell here: https://github.com/angular/components/issues/4803

like image 34
matt1616 Avatar answered Oct 24 '22 08:10

matt1616