Skip to content

Instantly share code, notes, and snippets.

@easrng
Created March 11, 2020 23:39
Show Gist options
  • Save easrng/b324c930ea8646eac8fc0dac56e564d6 to your computer and use it in GitHub Desktop.
Save easrng/b324c930ea8646eac8fc0dac56e564d6 to your computer and use it in GitHub Desktop.
A polyfill for font-family: system-ui; in CSS
(() => {
let div = document.createElement("div");
div.style.font = "menu"
document.body.appendChild(div)
let font = (getComputedStyle(div).fontFamily)
div.remove()
div = null;
let sele = document.createElement("style");
sele.textContent = `@font-face {
font-family: 'system-ui';
src: local('${font}');
}`;
document.body.appendChild(sele)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment