Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-ppi-size

Scales the size based on the device's ppi, make size looks same physical size across different devices.

Consider two device, ppi is 400 and 460, but both PixRatio.get() is 3,

Using dp size both scaled by 3, it looks different, on low-resolution may be too big, on high-resolution may be too small.

Note

only support New Architecture.

Installation

npm install react-native-ppi-size

Usage

import { scale, getDisplayMetrics } from 'react-native-ppi-size';

// scale size based on the device's ppi, default PPI = 160
const size = scale(100);

// custom ppi value
const PPI = 150;
const size = scale(100, PPI);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages