Search code examples
csshtmlweb-componentshadow-domcustom-element

Global CSS for an app with web components


I'm developing a web application that uses HTML 5 native web components. My problem is that I have a lot of common CSS for all of these and I use font awesome to have nice icons. Right now I put all my styles inside "/deep" shadow piercing but Chrome says : "/deep/ combinator is deprecated." Do you have any suggestions on how can I have global CSS and CSS libraries (like font awesome) available on the whole app ?

Thanks :)


Solution

  • You could include the CSS font file globally, with the <link rel="stylesheet"> element.

    Then, you'll have to import it locally in every Custom Element's <template>, in a <style> element, using the @import url CSS rule.

    There's a running example in this answer.