jj
    Preparing search index...

    Function fetchStyle

    • Fetches a CSS file and constructs a CSSStyleSheet.

      Parameters

      • url: string | URL

        The CSS file location.

      Returns Promise<CSSStyleSheet>

      The CSSStyleSheet object constructed from the CSS contents.

      This is particularly useful for Constructable Stylesheets, which can be shared across Shadow DOM boundaries.

      const sheet = await fetchStyle('./component.css')
      shadowRoot.adoptedStyleSheets = [sheet]

      If the fetch fails.