UNPKG

@codegouvfr/react-dsfr

Version:

French State Design System React integration library

14 lines 512 B
import { assert } from "tsafe/assert"; import { isBrowser } from "./isBrowser"; export function getBaseFontSizePx() { if (!isBrowser) { return 16; } const htmlElement = document.querySelector("html"); assert(htmlElement !== null); const computedStyle = window.getComputedStyle(htmlElement); const fontSize = computedStyle.getPropertyValue("font-size"); const fontSizeInPixels = parseFloat(fontSize); return fontSizeInPixels; } //# sourceMappingURL=getBaseFontSizePx.js.map