MCPcopy Create free account
hub / github.com/adobe/react-spectrum / pxToRem

Function pxToRem

packages/@react-spectrum/s2/style/spectrum-theme.ts:50–61  ·  view source on GitHub ↗
(px: string | number)

Source from the content-addressed store, hash-verified

48}
49
50function pxToRem(px: string | number) {
51 if (typeof px === 'string') {
52 px = parseFloat(px);
53 }
54
55 // In the docs, we need to be able to simulate font size adjustment.
56 if (process.env.DOCS_ENV) {
57 return `calc(${px / 16} * var(--rem, 1rem))`;
58 }
59
60 return px / 16 + 'rem';
61}
62
63function hcmColor(color: string) {
64 // In the docs, HCM colors can be simulated.

Callers 5

generateSpacingFunction · 0.70
spaceFunction · 0.70
sizeFunction · 0.70
spectrum-theme.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected