Re:Shoelace: A library of web components
by mattlondon on Thursday January 11, 2024 @01:35AM
(#38948584)
The CSS doesn't need to be in the JS. You can trivially just fetch the static CSS file in JS then have the content adopted.
Yeah but flash of unstyled content? Plus you need to somehow adopt only related parts? Selectors wouldnt match easily necessarily, e.g. decision to adopt :hover selector must be made somehow
I think this library does what you want:
https://shoelace.style/getting-started/customizing#css-parts
I guess it’s most-but-not-all part that got me confused. The are parts re-exported Manually? I guess that works
https://webcomponents.dev/blog/all-the-ways-to-make-a-web-co...
Yet, they are all Tools, and you don't learn a Technology by learning a Tool, or do you become a Writer when you learn Word?
``::part`` is part [sic] of the Standard, it doesn't require any tooling.
CCS in JS is your choice
1) Uses slots for composition
2) Does not use CSS-in-JS
3) Lightweight
I understand that slots imply shadow Dom, and then shadow Dom usually means adding/adopting stylesheets into components, and that means css in js.
But there's also ::part that allows piercing the shadow dom. Is there any library that uses it?