What is the recommended way to customize styles for a 3rd party component that I have downloaded via npm
?
For example the component ng2-tag-input
. I run a webpack build that bundles all the 3rd party js-files into a vendor.js and all the 3rd party css into a vendor.css
.
Since this is generated upon build, I don't want to make changes to vendor.css
or commit it.
Say that I want to add my own styles to ng2-tag-input
, how does one best do that? Should I just override its styles in my own site.css
or is there another way?
You can set
encapsulation: ViewEncapsulation.none
in your outermost component to apply styles globally. Then use that css file as your place for global styles.app.component.ts:
As @anonymvs mentioned you need to use higher specificity. One easy way to help with this, if you are using sass or similar, is to put all of your styles in a very specific block, eg:
app.component.scss: