Open hasdfa opened 4 months ago
The ?inline
in import will definitely not work with the way we are exporting the public api/files.
Also, Pigment CSS doesn't deal with shadow dom right now. All the css is extracted similar to how you'd write css modules. So all the generated classe names are random (but deterministic). Ideally, this shouldn't affect the page styles, unless you are also writing global css.
@brijeshb42 I'd love to have Shadow DOM support for PigmentCSS. Let me explain: in our internal infrastructure, we have a need to render our components in both light and dark themes at the same time, alongside with each other, in the same global DOM.
Forcing a specific color scheme doesn't work (see this issue), so we cannot rely on that API to have both <div className="light">
and <div className="dark">
at the same time.
The only reliable way for us for now is relying on Shadow DOM to isolate CSS selectors. It seems to work with 6.1.2 (thank you @siriwatknp!), but we really want to move to PigmentCSS without having to change our internal infrastructure.
Let me know if that makes sense. Thanks for your work
Summary
When you're using shadow root, styles are injected in the
head
of the document - so it's not possible to use pigment CSS with shadow dom.Examples
Vite.js (import of .css file)
https://codesandbox.io/p/devbox/pigment-css-shadow-dom-lf6tck?file=/src/index.tsx:20,1
Vite.js (inline import)
https://codesandbox.io/p/devbox/pigment-css-shadow-dom-lf6tck?file=/src/index-inline.tsx:11,1
Motivation
Search keywords: shadow dom