UMD Web Utilities Library
    Preparing search index...

    Function createStyleTemplate

    • Creates a template element containing a style tag

      Utility for creating HTML template elements with embedded CSS styles, commonly used for injecting styles into Shadow DOM.

      Parameters

      • styles: string

        CSS string to inject into the style tag

      Returns HTMLTemplateElement

      HTMLTemplateElement containing the styles

      const template = createStyleTemplate(`
      .container {
      display: flex;
      gap: 1rem;
      }
      `);
      shadowRoot.appendChild(template.content.cloneNode(true));