Composition with the Shadow DOM is more powerful than you think. You can do a lot with the default named slot assignment, but manual slot assignment is a pathway to many abilities some consider to be… unnatural.</emperor-palpatine>
Composition with the Shadow DOM is more powerful than you think. You can do a lot with the default named slot assignment, but manual slot assignment is a pathway to many abilities some consider to be… unnatural.</emperor-palpatine>
Web Components: Working With Shadow DOM, by @smashingmag:
https://www.smashingmagazine.com/2025/07/web-components-working-with-shadow-dom/
Public CSS Custom Properties in the Shadow DOM, by @michaelwarren.dev:
#Development #Guides
Public CSS variables in the shadow DOM · How to expose them in web components https://ilo.im/165h87
_____
#CustomProperties #WebComponents #ShadowDOM #API #Accessibility #WebDev #Frontend #CSS #JavaScript
After a long while tinkering with smaller and smaller ways to build re-usable pieces of HTML, I've landed on something that is simple, and uses the browsers built-in abilities to upgrade elements.
Introducing "ShadowRoot Injector"
https://github.com/Tram-One/shadowroot-injector
ShadowRoot Injector is a way to declaratively define HTML, that will automatically insert when custom elements appear in the DOM.
Check out the link and examples, and let me know what y'all think!
#WebComponents #HTML #ShadowDOM #WebDev
#WebComponents people, in this Codepen that I set up for testing, the dialog inside the #ShadowDOM cannot be open by its sibling button even enough they're connected by correct ID attribute.
Is this expected or am I missing something here?
#Development #Pitfalls
All browsers get this wrong · What DevTools misinterpret about Shadow DOM https://ilo.im/163dax
_____
#Bugs #Specification #WebComponents #ShadowDOM #DevTools #Browser #WebDev #Frontend #DOM #CSS
New Kitten release
• Now leaves <style> tags within <template> tags alone when collating and normalising the CSS on a page so as not to interfere with scoped styles in declarative shadow DOM.
(Kitten’s Streaming HTML workflow¹ – which uses htmx and WebSockets under the hood – combined with built-in support for slots, etc., in Kitten components² means the use of declarative shadow DOM is mostly useful if you want scoped styles. Ideally, of course, use classes to scope styles to your components and be specific in your CSS selectors in general so as not to pollute elements in your components. Although that’s a bit like saying you should floss everyday. Yeah, we all know we should…) :)
Update: All that said, I’d highly recommend you don’t use Shadow DOM in your Kitten apps. For one thing, htmx’s WebSocket extension doesn’t seem to play well with it. And for another, you really don’t need it and definitely not just to get scoped CSS.
Enjoy!
¹ https://kitten.small-web.org/tutorials/streaming-html/
² https://kitten.small-web.org/tutorials/components-and-fragments/
In that it was dropped as part of a thread that you might have otherwise been uninterested in, sharing this again to start your Thursday:
https://blog.westbrookjohnson.com/patterns/i-am-feeling-so-disconnected/
Catch up on some techniques for managing connection time work in a custom element. There's even reasons for using shadow DOM hidden in there.
Thanks @nachtfunke for starting the convo on this and @zachleat for challenging a toot into a full on blog dump.
@zachleat @nachtfunke I'm not saying this is because I didn't get you anything for your birthday, but I'm also not saying it isn't because of that...
https://blog.westbrookjohnson.com/patterns/i-am-feeling-so-disconnected/
https://github.com/w3c/csswg-drafts/issues/10013#issuecomment-2627222385
Call to action for #WebComponent / #ShadowDOM fans: I've added an experimental flag to Firefox lifting the restriction on adoptedStyleSheets, meaning shadowroots can adopt `link.sheet` or `style.sheet`.
Please try this out, and let me know if you encounter issues!
I think #CSS vars are good enough for bridging styles from a page into it's #webComponents' #shadowDOM
I’ve never had stress around putting all my #CSS for all of my #webComponent in their #shadowDOM… ask me anything.
@knowler MDN accepts PRs…
I started working on https://github.com/Westbrook/axe-core-element-internals as a test bed for #ElementInternals usage for ace-core, but maybe more useful at large for these APIs. I accept PRs, too.
Also, we’re looking to reignite the push for community docs and guides for WCs in https://discord.gg/KzgaSbGc9q to clarify these sorts of things, as well.
@brucelawson and, it’s behind the Experimental Web Platform Features flag in Chromium, so you can try it out today!!
I can maybe see CSS modules / constructible stylesheets kind of gives a browser primitive for CSS in a way which aligns more with this model. Though it kind of requires #ShadowDOM for scoping to work in any reasonable fashion, and without a clear scoping story I don't think it's quite there yet. Also it's not that far off from a string literal of CSS IMHO.
@patrickbrosset I've used it like this in the past: https://github.com/adobe/spectrum-web-components/blob/main/tools/shared/src/get-deep-element-from-point.ts Specifically to get information through shadow roots.
However, I'm not sure whether it should cross shadow boundaries on its own. I could maybe see an option, so you had to do work to get through, but didn't need to write your own recursive method.
Hi #webComponents friends, new and old!
So many of you in recent days, was there some kind of drama?
Thing won't always be this exciting, but I hope together we make make the web a little better place.
At times that might mean participating in the #webComponentsCG. Come hang out: https://github.com/w3c/webcomponents-cg
Others will just be sharing ideas about #webDev #shadowDOM #CSS #customElements #w3c, etc.
What about you? What are you working on/learning about? Let people know in the thread!
Some others:
@trusktr
@stuffbreaker
@jaredwhite
@graynorton
@nikkimk
And of course the whole hash tags of: