2 ms·
why not use web components?
by cranberryturkey 2y ago
why not use web components?
- dtagames 2y agoI second this suggestion. Web components and the shadow DOM provide a fully isolated "namespace" where you can keep CSS from leaking out into other components. You can still include shared CSS in those files so you get the best of both worlds.
- PaulHoule 2y ago... I just found I can do that with HTMX https://htmx.org/examples/web-components/ https://htmx.org/examples/web-components/ thanks!
- PaulHoule 2y agoI like the template and slots mechanisms described here: https://developer.mozilla.org/en-US/docs/Web/API/Web_components https://developer.mozilla.org/en-US/docs/Web/API/Web_compone... and I see some CSS pseudo-classes but I don't see anything I can use to suppress the host site's CSS acting on my UI elements -- am I missing something?
- cranberryturkey 2y agoif you use the shadow dom, your component won't inherit css rules from the parent site.
- mejutoco 2y agoBe default css rules cannot affect the internals of web components. They can only read variables.