4 ms·
As a huge fan of Web Components, I'm sort of strangely on the other side of shadow dom. I've been doing 100% of my UI work using vanilla Web Components for yea
by claytongulick 4y ago
As a huge fan of Web Components, I'm sort of strangely on the other side of shadow dom.
I've been doing 100% of my UI work using vanilla Web Components for years now, and what I generally recommend is to avoid the use of shadow dom unless there's a good reason for it.
The CSS parts API is difficult to work with, and if you want to use a CSS framework like bootstrap etc... you end up importing all the CSS into the component's shadow context.
Web Components with the light dom work great, they're an effective encapsulation mechanism. I'm not sure why most examples you see with WC go straight to shadow DOM.
It isn't necessary for most components and adds an lot of styling complexity.
- robbiejs 4y agoInteresting. What is the added styling complexity? I am interested in using Shadow DOM for the next version of my component DataGridXL (https://www.datagridxl.com/ https://www.datagridxl.com/) to prevent outside CSS from affecting the component. WHy do you say it is not worth it?
- claytongulick 4y agoFor that case, I probably would use Shadow DOM, it's great for library components. For application development, I prefer the light DOM.
- microflash 4y agoThis. I've started using web components extensively and eventually came to the same conclusion.
- robbiejs 4y agoSo the components you are talking about are simpler UI components for which Shadow DOM is overkill? For advanced components like a grid, you would still recommend going with Shadow Dom?