3 ms·
Watch out for the Web Component gotchas, though: the shadow DOM encapsulates the CSS cascade meaning your styles will not apply to your components unless you ex
by eurasiantiger 4y ago
Watch out for the Web Component gotchas, though: the shadow DOM encapsulates the CSS cascade meaning your styles will not apply to your components unless you explicitly apply them to each one. Also, events don’t automatically bubble up!
- mhoad 4y agoIt’s actually not a huge deal in practice. I just put together a content style website using nothing but web components and used a base class to put my global styles into and just inherited my various components from it. Was also really easy to factor out shareable styles like various page layouts using a similar technique. That just left me with doing small targeted tweaks where I would override things with custom properties along the way as needed plus any component specific styles. Was probably the cleanest approach I’ve had in as long as I could remember. Plus it was delivering me a perfect 100 score in Lighthouse too for what it’s worth. Would recommend.