Dimensions API provides access to device screen dimensions. Use it to get the width and height of the window and screen, and listen for dimension changes (like device rotation).
Import
For React components, prefer using the
useWindowDimensions hook instead of Dimensions.get() for automatic updates on dimension changes.Methods
get()
Returns the dimensions for a given dimension type.string
required
The dimension type to retrieve:
'window': The visible window dimensions (excludes status bar, navigation bar on Android)'screen': The entire screen dimensions (includes status bar, navigation bars)
DisplayMetrics object with:
width(number): Width in pixelsheight(number): Height in pixelsscale(number): Pixel density (e.g., 2 for @2x, 3 for @3x)fontScale(number): Font scaling factor for accessibility
addEventListener()
Add a listener for dimension changes.string
required
Must be
'change' - fires when dimensions change (e.g., device rotation).function
required
Callback invoked with an object containing
window and screen dimensions.EventSubscription - Object with a remove() method to unsubscribe.
Types
DisplayMetrics
DimensionsPayload
Examples
Basic Usage
Responsive Styles
Listening to Dimension Changes
Using useWindowDimensions Hook
Orientation Detection
Responsive Grid Layout
Platform-Specific Dimensions
Dynamic Font Sizing
Window vs Screen
window
- Represents the visible application area
- iOS: Excludes status bar
- Android: Excludes status bar and bottom navigation bar (if using edge-to-edge mode)
- Recommended for most layout calculations
screen
- Represents the entire physical screen
- Includes all system UI elements
- Remains constant even when keyboard is visible
- Useful for fullscreen calculations
Understanding Scale
Thescale property indicates the pixel density:
1: Standard resolution (mdpi on Android)2: Retina/@2x (iPhone 8, xhdpi on Android)3: Super Retina/@3x (iPhone 14, xxhdpi on Android)
Best Practices
The
fontScale property reflects the user’s font size accessibility setting. Multiply your font sizes by this value to respect user preferences.