Skip to content

useDevicePixelRatio

Hook that returns the device's pixel ratio

utilities
low
test coverage
Last changed: 6 months ago

Installation

Library
CLI
Manual
typescript
import { useDevicePixelRatio } from '@siberiacancode/reactuse';

Usage

typescript
const { supported, ratio } = useDevicePixelRatio();
## Demo

Api

Returns

UseDevicePixelRatioReturn

Type declaration

typescript
export interface UseDevicePixelRatioReturn {
  /** The ratio of the resolution in physical pixels to the resolution in CSS pixels */
  ratio: number;
  /** Whether the device pixel ratio is supported*/
  supported: boolean;
}

Source

SourceDemo

Contributors

D
debabin
debabin
A
Artem Dereviago
Artem Dereviago

Released under the MIT License.