Get the UIKit UIWindow
values for UITraitCollection
vertical and horizontal size classes in iOS. Safe for Android (it's a no-op).
Using npm:
npm install --save react-native-size-classes
Using yarn:
yarn add react-native-size-classes
react-native link react-native-size-classes
or with rnpm:
rnpm link react-native-size-classes
import SizeClasses from 'react-native-size-classes'
The API currently supports iOS only. You'll probably want to wrap calls in Platform.OS
or Platform.select()
.
Uses the UIWindow
to return a Promise that resolves values for vertialSizeClass
and horizontalSizeClass
for the overall app.
SizeClasses.getSizeClasses().then((sc) => console.log(sc.vertical))
Uses the UIWindow
value for userInterfaceIdiom
to determine if this device is an iPad or not.
const isIpad = SizeClasses.isIpad(); //true