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 DOMgetRootFontSize
Reads the root font size in pixels, for converting rem to px.
Usage
API
| Name | Description | Type | Default |
|---|---|---|---|
getRootFontSize(fallback?) | The :root font size in pixels. Returns fallback on the server or when the value does not parse. | (fallback = 16) => number | — |