UtilOptional

getRootFontSize

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

Usage

import { getRootFontSize } from 'ngwr/utils';

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

API

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

See also