Shadow DOM
Injecting into a shadow root
Section titled “Injecting into a shadow root”The shadow-root injection helpers need the scrollsheet/auto entry, which embeds the stylesheet.
The default entry ships no embedded CSS, so its injectStylesInto has nothing to inject and
does nothing. Import everything from scrollsheet/auto and call injectStylesInto once per
shadow root, before any Sheet.Content inside it opens:
import { Sheet, injectStylesInto } from 'scrollsheet/auto';
injectStylesInto(shadowRoot);How it works
Section titled “How it works”The helper adds the core stylesheet to the shadow root through adoptedStyleSheets. This
styles the trigger and surrounding markup, which cannot inherit styles from document.head.
Without constructable stylesheets (Safari < 16.4), it appends a <style> tag inside the shadow
root. The <dialog> still portals to document.body. Put custom panel classes in a
document-level stylesheet too; shadow-scoped CSS cannot style the portaled panel.
Toast styles
Section titled “Toast styles”Use injectToastStylesInto for the separate toast stylesheet. Apps that only use sheets do
not include it:
import { injectToastStylesInto } from 'scrollsheet/auto';
injectToastStylesInto(shadowRoot);