Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Inject CSS
public onInit(): Promise<void> {, `Initialized ${strings.Title}`);
const cssUrl: string =;
if (cssUrl) {
// inject the style sheet
const head: any = document.getElementsByTagName("head")[0] || document.documentElement;
let customStyle: HTMLLinkElement = document.createElement("link");
customStyle.href = cssUrl;
customStyle.rel = "stylesheet";
customStyle.type = "text/css";
head.insertAdjacentElement("beforeEnd", customStyle);
return Promise.resolve();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment