Skip to main content
The 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)
Returns: DisplayMetrics object with:
  • width (number): Width in pixels
  • height (number): Height in pixels
  • scale (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.
Returns: 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

The scale property indicates the pixel density:
Common scale values:
  • 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

Use useWindowDimensions() hook in React components instead of Dimensions.get() for automatic updates on dimension changes.
Don’t cache dimension values in StyleSheet.create() - dimensions won’t update on rotation. Calculate styles dynamically or use state.
The fontScale property reflects the user’s font size accessibility setting. Multiply your font sizes by this value to respect user preferences.

Common Pitfalls

Static Styles Don’t Update

Missing Cleanup