UtilUpdated in v16Optional

wrGetRootFontSize

Reads the root font size in pixels, for converting rem to px.

Usage

import { wrGetRootFontSize } from 'ngwr/utils';

const px = wrGetRootFontSize();         // e.g. 16
const remToPx = 2 * px;               // '2rem' in pixels
const onServer = wrGetRootFontSize(14); // 14 when there is no DOM

API

NameDescriptionTypeDefault
wrGetRootFontSize(fallback?)The :root font size in pixels. Returns fallback on the server or when the value does not parse.(fallback = 16) => number—

See also