fn

pxValue

v0.0.5

Parse a CSS length token ("1024px", "48em", "30rem", "50%") into a pixel number. em/rem use the conventional 16px root size. Returns NaN for non-numeric input.

Example

ts
pxValue('30rem'); // 480
pxValue('1024px'); // 1024

Signature

ts
declare function pxValue(value: string): number;

Parameters

ParameterTypeDescription
valuestringThe CSS length token to parse

Returns

numberThe value in pixels, or NaN when not parseable