A simple package enabling vw
, vh
, vmin
, vmax
units for measurement in React Native.
TypeScript Declarations included.
$ npm install react-native-viewport-ts-units
or
$ yarn add react-native-viewport-ts-units
Simply call the functions to size your components.
import { vw, vh, vmin, vmax } from "react-native-viewport-ts-units";
<View style={{ width: vw(100), height: vh(100) }}>
...
<View>
const styles = StyleSheet.create({
Container: {
width: vmin(95),
height: vmax(70),
padding: vw(2.5),
margin: vh(5),
},
Font: {
fontSize: vw(3.75),
},
});
MIT © Ronit Bhatia