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

Vue3 datepicker: scoped styles not working

I am using Vuepic/ Vue3Datepicker and I want to customize the way a selected date looks like. As per the documentation, we can do that this way for the light mode:

<style>
.dp__theme_light {
  --dp-highlight-color: rgba(34, 233, 8, 0.993);
  --dp-primary-color: #ff006f;
  --dp-primary-text-color: #000078;
}
</style>

This works fine except this applies to all the component where I use this date picker:

enter image description here

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

The solution is to write:

<style scoped>
  ...
</style> 

but this does not work at all: the style does not apply neither in this specific component nor elsewhere. id est, I the default theme colors apply in this case, and mine are ignored:

enter image description here

Anything I missed ?

>Solution :

For scoped CSS to affect child components target a class on the root child element and use the :deep() selector on the class you actually want to target

<style scoped>
.dp__main :deep(.dp__theme_light) {
  --dp-highlight-color: rgba(34, 233, 8, 0.993);
  --dp-primary-color: #ff006f;
  --dp-primary-text-color: #000078;
}
</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