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 color of the text in the thumb-label of the Vuetify v-slider component?

I have been struggling for a bit now, and my goal is to give the thumb label of my v-slider a custom color, defined in the part of my component. How do I do that?

Thanks, Joost

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 :

If you Inspect Element using Chrome DevTools you can usually find which classes need css applying to it. In this case, it’s .v-slider-thumb__label. To access these classes (in a scoped style section), you need a :deep selector:

<style scoped>
  :deep(.v-slider-thumb__label) {
    background-color: red;
  }
  :deep(.v-slider-thumb__label::before) {
    color: red;
  }
</style>

If you need it to reflect a color defined in your script, you can do as follows:

<script setup>
  //...

  const color = ref('red')
</script>

<style scoped>
  :deep(.v-slider-thumb__label) {
    background-color: v-bind(color);
  }
  :deep(.v-slider-thumb__label::before) {
    color: v-bind(color);
  }
</style>
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