usePixelDensity()v4.0.472
Returns the pixel density factor for the current Remotion render or preview.
During preview, this is window.devicePixelRatio. During rendering, this is the scale option.
MyComp.tsximport {usePixelDensity } from 'remotion'; export constMyComp = () => { constpixelDensity =usePixelDensity (); return <div >Pixel density: {pixelDensity }</div >; };
If the hook is called outside a Remotion context, it throws an error. To return the browser pixel density outside of Remotion, pass dontThrowIfOutsideOfRemotion: true. In environments without window.devicePixelRatio, the hook returns 1.
MyRegularReactComponent.tsximport {usePixelDensity } from 'remotion'; export constMyRegularReactComponent = () => { constpixelDensity =usePixelDensity ({dontThrowIfOutsideOfRemotion : true, }); return <div >Pixel density: {pixelDensity }</div >; };
Compatibility
| Browsers | Environments | |||||
|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | ||||