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

Spacer

A SwiftUI Spacer component for flexible spacing.

Expo UI Spacer matches the official SwiftUI Spacer API and expands to fill available space in a stack.

Usage

Basic spacer in HStack

Use Spacer to push content to opposite ends of a horizontal stack.

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

export default function SpacerHStackExample() {
  return (
    <Host style={{ flex: 1 }}>
      <HStack>
        <Text>Left</Text>
        <Spacer />
        <Text>Right</Text>
      </HStack>
    </Host>
  );
}
The word Left at the leading edge and Right at the trailing edge of the same row
The word Left at the leading edge and Right at the trailing edge of the same row

Basic spacer in VStack

Use Spacer to push content to opposite ends of a vertical stack.

import { Host, VStack, Text, Spacer } from '@expo/ui/swift-ui';

export default function SpacerVStackExample() {
  return (
    <Host style={{ flex: 1 }}>
      <VStack>
        <Text>Top</Text>
        <Spacer />
        <Text>Bottom</Text>
      </VStack>
    </Host>
  );
}
The word Top at the upper edge and Bottom at the lower edge of the same column
The word Top at the upper edge and Bottom at the lower edge of the same column

API

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

Component

Spacer

Type: React.Element<SpacerProps>

SpacerProps

minLength

Optional • Type: number

The minimum length of the spacer. This is the minimum amount of space that the spacer will take up.

Inherited props

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 Spacer, but not all of them do something here.

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

Best modifiers for Spacer

These modifiers are the ones that you use most with Spacer.

Also works on Spacer

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

Needs care on Spacer

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

ModifierWhat to know
frameUse minWidth or minHeight to give the spacer a smallest size. A fixed size stops it from growing.

No visible effect on Spacer

Spacer 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 Spacer takes no child views.
allowsTighteningIt changes only text, and Spacer shows no text.
backgroundIt paints in the area of the view, and Spacer draws nothing that you can see.
backgroundOverlayIt paints in the area of the view, and Spacer draws nothing that you can see.
blurIt changes how the view is drawn, and Spacer draws nothing that you can see.
boldIt changes only text and SF Symbols, and Spacer shows neither.
borderIt changes how the view is drawn, and Spacer draws nothing that you can see.
brightnessIt changes how the view is drawn, and Spacer draws nothing that you can see.
clippedIt changes how the view is drawn, and Spacer draws nothing that you can see.
clipShapeIt changes how the view is drawn, and Spacer draws nothing that you can see.
colorInvertIt changes how the view is drawn, and Spacer draws nothing that you can see.
containerShapeIt sets the shape that the child views use for containerRelativeShape, and Spacer takes no child views.
contentShapeIt changes the area that gets touches, and Spacer gets no touches of its own.
contentTransition iOS 16+It changes how text and SF Symbols animate when their content changes, and Spacer shows neither.
contrastIt changes how the view is drawn, and Spacer draws nothing that you can see.
cornerRadiusIt changes how the view is drawn, and Spacer draws nothing that you can see.
disabledIt turns off the controls in the view, and Spacer has none.
dynamicTypeSizeIt changes only text and SF Symbols, and Spacer shows neither.
fontIt changes only text and SF Symbols, and Spacer shows neither.
foregroundColorIt changes how the view is drawn, and Spacer draws nothing that you can see.
foregroundStyleIt changes how the view is drawn, and Spacer draws nothing that you can see.
geometryGroup iOS 17+It works on the child views that you give the component, and Spacer takes none.
glassEffectIt paints in the area of the view, and Spacer draws nothing that you can see.
grayscaleIt changes how the view is drawn, and Spacer draws nothing that you can see.
hiddenIt hides what the view draws, and Spacer draws nothing that you can see.
hueRotationIt changes how the view is drawn, and Spacer draws nothing that you can see.
imageScaleIt changes only SF Symbols, and Spacer shows none.
italicIt changes only text, and Spacer shows no text.
kerningIt changes only text, and Spacer shows no text.
lineHeight iOS 26+It changes only text, and Spacer shows no text.
lineLimitIt changes only text, and Spacer shows no text.
lineSpacingIt changes only text, and Spacer shows no text.
luminanceToAlphaIt changes how the view is drawn, and Spacer draws nothing that you can see.
maskIt changes how the view is drawn, and Spacer draws nothing that you can see.
minimumScaleFactorIt changes only text, and Spacer shows no text.
monospacedDigitIt changes only text, and Spacer shows no text.
multilineTextAlignmentIt changes only text, and Spacer shows no text.
offsetIt changes how the view is drawn, and Spacer draws nothing that you can see.
onAppearIn SDK 57, Spacer does not send modifier events to JavaScript, so the handler does not run.
onDisappearIn SDK 57, Spacer does not send modifier events to JavaScript, so the handler does not run.
onGeometryChangeIn SDK 57, Spacer does not send modifier events to JavaScript, so the handler does not run.
onLongPressGestureIn SDK 57, Spacer does not send modifier events to JavaScript, so the handler does not run.
onTapGestureIn SDK 57, Spacer does not send modifier events to JavaScript, so the handler does not run.
opacityIt changes how the view is drawn, and Spacer draws nothing that you can see.
overlayIt paints in the area of the view, and Spacer draws nothing that you can see.
redactedIt changes how the view is drawn, and Spacer draws nothing that you can see.
rotation3DEffectIt changes how the view is drawn, and Spacer draws nothing that you can see.
rotationEffectIt changes how the view is drawn, and Spacer draws nothing that you can see.
saturationIt changes how the view is drawn, and Spacer draws nothing that you can see.
scaleEffectIt changes how the view is drawn, and Spacer draws nothing that you can see.
shadowIt changes how the view is drawn, and Spacer draws nothing that you can see.
strikethroughIt changes only text, and Spacer shows no text.
strokeBorderIt changes how the view is drawn, and Spacer draws nothing that you can see.
textCaseIt changes only text, and Spacer shows no text.
tintIt changes the accent colour of controls and SF Symbols, and Spacer shows neither.
truncationModeIt changes only text, and Spacer shows no text.
underlineIt changes only text, and Spacer shows no text.
zIndexIt changes the order of views that cover each other in the same parent, and Spacer 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