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

Ignore styles from outside the component

I use my Vue component inside an existing page with some global styles for input elements.
Now I don’t want them to affect the elements inside the component. How would I achieve the component ignoring stylesheats not included in the main.js file or included in the respective component?

>Solution :

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

In your single file component you can add scoped keyword.

<template>
  <div class="has-red-color">test</div>
</template>

<style scoped>
.has-red-color {
  color: red !important;
}
</style>

Scoped keyword just use this style when you add this component.

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