Skip to main content
A React component for displaying different types of images, including network images, static resources, temporary local images, and images from local disk, such as the camera roll.

Import

import { Image } from 'react-native';

Basic Usage

import React from 'react';
import { Image, StyleSheet } from 'react-native';

function BasicImage() {
  return (
    <Image
      source={{ uri: 'https://reactnative.dev/img/tiny_logo.png' }}
      style={styles.image}
    />
  );
}

const styles = StyleSheet.create({
  image: {
    width: 50,
    height: 50,
  },
});

Props

Source Props

source
ImageSource
required
The image source (either a remote URL or a local file resource). This prop can also contain several remote URLs, specified together with their width and height. The native side will then choose the best URI to display based on the measured size of the image container.Supported formats: png, jpg, jpeg, bmp, gif, webp (Android only), psd (iOS only)
src
string
A string representing the resource identifier for the image. Similar to src from HTML.
srcSet
string
Similar to srcset from HTML. Specifies multiple image sources for different display densities.

Display Props

resizeMode
'cover' | 'contain' | 'stretch' | 'repeat' | 'center'
Determines how to resize the image when the frame doesn’t match the raw image dimensions.
  • cover - Scale the image uniformly (maintain aspect ratio) so that both dimensions will be equal to or larger than the corresponding dimension of the view
  • contain - Scale the image uniformly so that both dimensions will be equal to or less than the corresponding dimension of the view
  • stretch - Scale width and height independently, may change the aspect ratio of the src
  • repeat - Repeat the image to cover the frame of the view (iOS only)
  • center - Scale the image down so that it is completely visible, if bigger than the view area
width
number
Width of the image component.
height
number
Height of the image component.
style
ImageStyle
Styles to apply to the image.

Visual Props

blurRadius
number
The blur radius of the blur filter added to the image.
tintColor
color
Changes the color of all the non-transparent pixels to the tintColor.

Accessibility Props

accessible
boolean
When true, indicates the image is an accessibility element.
accessibilityLabel
string
The text that’s read by the screen reader when the user interacts with the image.
alt
string
Alias for accessibilityLabel. The text that’s read by the screen reader when the user interacts with the image.
aria-label
string
Alias for accessibilityLabel.

Network Props

crossOrigin
'anonymous' | 'use-credentials'
Adds the CORS related header to the request. Similar to crossorigin from HTML.
referrerPolicy
string
A string indicating which referrer to use when fetching the resource. Similar to referrerpolicy from HTML.Options: ‘no-referrer’, ‘no-referrer-when-downgrade’, ‘origin’, ‘origin-when-cross-origin’, ‘same-origin’, ‘strict-origin’, ‘strict-origin-when-cross-origin’, ‘unsafe-url’

Event Handlers

onLoad
(event: ImageLoadEvent) => void
Invoked when load completes successfully. Event data includes the image source dimensions and URI.
onLoadStart
() => void
Invoked on load start.
onLoadEnd
() => void
Invoked when load either succeeds or fails.
onError
(event: ImageErrorEvent) => void
Invoked on load error with {nativeEvent: {error}}.
onLayout
(event: LayoutEvent) => void
Invoked on mount and layout changes with {nativeEvent: { layout: {x, y, width, height}}}.

Identification Props

testID
string
A unique identifier for this element to be used in UI Automation testing scripts.

Platform-Specific Props

defaultSource
ImageSource
A static image to display while loading the image source.
onPartialLoad
() => void
Invoked when a partial load of the image is complete.
onProgress
(event: ImageProgressEvent) => void
Invoked on download progress with {nativeEvent: {loaded, total}}.
capInsets
Insets
When the image is resized, the corners specified by capInsets will stay a fixed size, but the center content and borders will be stretched.

Examples

Network Image

import { Image, StyleSheet } from 'react-native';

function NetworkImage() {
  return (
    <Image
      source={{
        uri: 'https://reactnative.dev/img/tiny_logo.png',
        width: 64,
        height: 64,
      }}
      style={styles.image}
    />
  );
}

const styles = StyleSheet.create({
  image: {
    width: 64,
    height: 64,
  },
});

Local Image

import { Image, StyleSheet } from 'react-native';

function LocalImage() {
  return (
    <Image
      source={require('./assets/logo.png')}
      style={styles.image}
    />
  );
}

const styles = StyleSheet.create({
  image: {
    width: 100,
    height: 100,
  },
});

Image with Loading States

import { Image, ActivityIndicator, View, StyleSheet } from 'react-native';
import { useState } from 'react';

function ImageWithLoading() {
  const [loading, setLoading] = useState(true);

  return (
    <View style={styles.container}>
      {loading && <ActivityIndicator style={styles.loader} />}
      <Image
        source={{ uri: 'https://example.com/image.jpg' }}
        style={styles.image}
        onLoadStart={() => setLoading(true)}
        onLoadEnd={() => setLoading(false)}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    width: 200,
    height: 200,
  },
  loader: {
    position: 'absolute',
    left: '50%',
    top: '50%',
  },
  image: {
    width: 200,
    height: 200,
  },
});

Multiple Resolution Images

import { Image, StyleSheet } from 'react-native';

function MultiResImage() {
  return (
    <Image
      source={[
        { uri: 'https://example.com/[email protected]', width: 100, height: 100 },
        { uri: 'https://example.com/[email protected]', width: 200, height: 200 },
        { uri: 'https://example.com/[email protected]', width: 300, height: 300 },
      ]}
      style={styles.image}
    />
  );
}

const styles = StyleSheet.create({
  image: {
    width: 100,
    height: 100,
  },
});

Build docs developers (and LLMs) love