Expo UI and Router for iOSExpo SDK 57 and later, iOS only
Components

Image

A SwiftUI Image component for displaying SF Symbols. Also called Icon (Universal).

Expo UI Image displays SF Symbols using the SwiftUI Image API. SF Symbols are a library of configurable symbols provided by Apple.

Usage

Basic SF Symbol

import { Host, Image } from '@expo/ui/swift-ui';

export default function BasicImageExample() {
  return (
    <Host style={{ flex: 1 }}>
      <Image systemName="star.fill" />
    </Host>
  );
}
A star SF Symbol rendered at its default size
A star SF Symbol rendered at its default size

Custom SF Symbol

Use the assetName prop to display a custom SF Symbol imported into the app asset catalog as a symbol set.

import { Host, Image } from '@expo/ui/swift-ui';

export default function CustomImageExample() {
  return (
    <Host matchContents>
      <Image assetName="acme.mark" />
    </Host>
  );
}

With size and color

import { Host, HStack, Image } from '@expo/ui/swift-ui';

export default function ImageSizeColorExample() {
  return (
    <Host style={{ flex: 1 }}>
      <HStack spacing={16}>
        <Image systemName="heart.fill" size={24} color="red" />
        <Image systemName="star.fill" size={32} color="orange" />
        <Image systemName="bell.fill" size={40} color="blue" />
      </HStack>
    </Host>
  );
}
A red heart, an orange star, and a blue bell SF Symbol at increasing sizes
A red heart, an orange star, and a blue bell SF Symbol at increasing sizes

With variable value

Some SF Symbols alter their appearance based on a variable value. Use the variableValue prop with a value between 0.0 and 1.0 to control the rendered symbol. Requires iOS 16.0+ and SF Symbols 4.0+.

import { Host, HStack, Image } from '@expo/ui/swift-ui';

export default function ImageVariableExample() {
  return (
    <Host style={{ flex: 1 }}>
      <HStack spacing={16}>
        <Image
          systemName="chart.bar.fill"
          size={32}
          variableValue={0.3}
        />
        <Image
          systemName="chart.bar.fill"
          size={32}
          variableValue={0.6}
        />
        <Image
          systemName="chart.bar.fill"
          size={32}
          variableValue={1.0}
        />
      </HStack>
    </Host>
  );
}
Three bar chart SF Symbols with variable values of 0.3, 0.6, and 1.0
Three bar chart SF Symbols with variable values of 0.3, 0.6, and 1.0

With symbol effect

Apply an SF Symbol effect to animate the symbol by passing a 0 modifier from @expo/ui/swift-ui/modifiers.

  • This effect runs continuously by default.
  • You can also pass value for a discrete trigger that fires once per change, or isActive for a boolean toggle that runs the effect while true.
  • Requires iOS 17.0 and later.
import { Host, Image } from '@expo/ui/swift-ui';
import { symbolEffect } from '@expo/ui/swift-ui/modifiers';

export default function ImageSymbolEffectExample() {
  return (
    <Host style={{ flex: 1 }}>
      <Image
        systemName="wifi"
        size={48}
        color="blue"
        modifiers={[
          symbolEffect({
            effect: 'variableColor',
            fillStyle: 'iterative',
            playbackStyle: 'reversing',
          }),
        ]}
      />
    </Host>
  );
}
A blue wifi SF Symbol shown during one frame of the variable color effect animation
A blue wifi SF Symbol shown during one frame of the variable color effect animation

The following example uses value to play bounce on each button press. Write to state.value from a worklet (or via scheduleOnUI) to trigger the effect.

import {
  Button,
  Host,
  Image,
  useNativeState,
  VStack,
} from '@expo/ui/swift-ui';
import { symbolEffect } from '@expo/ui/swift-ui/modifiers';
import { scheduleOnUI } from 'react-native-worklets';

export default function ImageSymbolEffectValueExample() {
  const trigger = useNativeState(0);

  return (
    <Host style={{ flex: 1 }}>
      <VStack spacing={16}>
        <Image
          systemName="bell.fill"
          size={48}
          color="orange"
          modifiers={[
            symbolEffect(
              { effect: 'bounce', direction: 'up' },
              { value: trigger }
            ),
          ]}
        />
        <Button
          label="Bounce"
          onPress={() =>
            scheduleOnUI(() => {
              'worklet';
              trigger.value = trigger.value + 1;
            })
          }
        />
      </VStack>
    </Host>
  );
}
An orange bell SF Symbol above a Bounce button
An orange bell SF Symbol above a Bounce button

The following example uses isActive to toggle a continuous breathe animation.

import {
  Host,
  Image,
  SyncToggle,
  useNativeState,
  VStack,
} from '@expo/ui/swift-ui';
import { symbolEffect } from '@expo/ui/swift-ui/modifiers';

export default function ImageSymbolEffectIsActiveExample() {
  const isActive = useNativeState(true);

  return (
    <Host style={{ flex: 1 }}>
      <VStack spacing={16}>
        <Image
          systemName="cloud.fill"
          size={48}
          color="cyan"
          modifiers={[
            symbolEffect({ effect: 'breathe' }, { isActive }),
          ]}
        />
        <SyncToggle label="Breathe" isOn={isActive} />
      </VStack>
    </Host>
  );
}
A cyan cloud SF Symbol above a Breathe toggle that is turned on
A cyan cloud SF Symbol above a Breathe toggle that is turned on

API

import { Image } from '@expo/ui/swift-ui';

Component

Image

Type: React.Element<ImageProps>

ImageProps

assetName

Optional • Type: string

The asset catalog name of a custom SF Symbol imported as a symbol set.

color

Optional • Type: ColorValue

The color of the system image. Can be a color name like '#ff00ff', 'red', 'blue', etc.

onPress

Optional • Type: () => void

Callback triggered when the view is pressed.

size

Optional • Type: number

The fixed size of the system image in points. Does not scale with Dynamic Type. Use the font modifier with textStyle for that. Ignored when a font modifier is supplied.

systemName

Optional • Type: SFSymbols7_0

The name of the system image (SF Symbol). For example: 'photo', 'heart.fill', 'star.circle'

uiImage

Optional • Type: string

The URI of the local image file to display. For example: 'file:///path/to/image.jpg' Performs a synchronous read operation that blocks the main thread.

Modifiers

Use these modifiers in the modifiers prop of the SwiftUI and Universal version.

Expo UI lets you put any of the 89 modifiers for any view on Image, but not all of them do something here.

  • 57 change what you see on Image.
  • 1 work, but not in the way that you may expect.
  • 19 have no visible effect on Image.
  • 13 work only in one place, such as a widget or a Grid.

Best modifiers for Image

These modifiers are made for Image, or they are the ones that you use most with it.

Also works on Image

Image takes these modifiers too, and each one works in the usual way.

Needs care on Image

These modifiers work on Image, but not in the way that you may expect.

ModifierWhat to know
fontSets the size and weight of an SF Symbol. It has no effect on a bitmap image. If you set no font, Image uses its size prop.

No visible effect on Image

Image accepts these modifiers, but you see no change. They do not give an error.

ModifierWhy nothing happens
accessibilityElementIt joins the child views into one accessibility element, and Image takes no child views.
allowsTighteningIt changes only text, and Image shows no text.
containerShapeIt sets the shape that the child views use for containerRelativeShape, and Image takes no child views.
disabledIt turns off the controls in the view, and Image has none.
geometryGroup iOS 17+It works on the child views that you give the component, and Image takes none.
italicIt changes only text, and Image shows no text.
kerningIt changes only text, and Image shows no text.
layoutPriorityIt has an effect only when the view shares an axis with other views in a stack.
lineHeight iOS 26+It changes only text, and Image shows no text.
lineLimitIt changes only text, and Image shows no text.
lineSpacingIt changes only text, and Image shows no text.
minimumScaleFactorIt changes only text, and Image shows no text.
monospacedDigitIt changes only text, and Image shows no text.
multilineTextAlignmentIt changes only text, and Image shows no text.
strikethroughIt changes only text, and Image shows no text.
textCaseIt changes only text, and Image shows no text.
truncationModeIt changes only text, and Image shows no text.
underlineIt changes only text, and Image shows no text.
zIndexIt changes the order of views that cover each other in the same parent, and Image does not stack its children.

Only in some places

These modifiers work only in a widget, in a Grid, in a Namespace or in a parent that asks for them.

ModifierWhere it works
activityBackgroundTintWorks only in a Live Activity. It has no effect in the app.
alignmentGuideHas an effect only when the parent, such as a VStack or ZStack, aligns its children by the same guide.
containerBackgroundWorks only in a widget, or in a navigation container when you use a navigation placement.
glassEffectIdWorks only on a view that also has glassEffect, in a GlassEffectContainer and a Namespace.
gridCellAnchor iOS 16+Works only on a cell of a Grid. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridCellColumnsWorks only on a view in a Grid.Row. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridCellUnsizedAxesWorks only on a view in a Grid. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridColumnAlignment iOS 16+Works only on a view in a Grid.Row. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
invalidatableContent iOS 17+Has an effect only when a parent view uses redacted with the invalidated reason.
matchedGeometryEffectWorks only in a Namespace. Give two views the same id and change between them with an animation.
privacySensitiveHas an effect only when a parent view uses redacted with the privacy reason.
unredactedHas an effect only in a parent view that uses redacted.
widgetURLWorks only in a widget. It has no effect in the app.

Sources

The original Expo docs for this page:

On this page