Components
Overlay
A SwiftUI Overlay component for layering content on top of another view.
Expo UI Overlay matches the official SwiftUI overlay modifier and provides a way to layer secondary content on top of a view, positioned with a specified alignment.
Usage
import { Host, Overlay, Text, Image } from '@expo/ui/swift-ui';
import {
foregroundStyle,
frame,
font,
background,
clipShape,
offset,
} from '@expo/ui/swift-ui/modifiers';
export default function OverlayExample() {
return (
<Host
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}}>
<Overlay alignment="topTrailing">
<Image
systemName="bell.fill"
modifiers={[
font({ size: 28 }),
foregroundStyle('#007AFF'),
]}
/>
<Overlay.Content>
<Text
modifiers={[
font({ size: 11, weight: 'bold' }),
foregroundStyle('#FFFFFF'),
frame({ width: 18, height: 18 }),
background('#FF3B30'),
clipShape('circle'),
offset({ x: 8, y: -8 }),
]}>
3
</Text>
</Overlay.Content>
</Overlay>
</Host>
);
}API
import { Overlay } from '@expo/ui/swift-ui';Component
Overlay
Type: React.Element<OverlayProps>
OverlayProps
alignment
Optional • Type: Alignment • Default: 'center'
The alignment of the overlay content relative to the base content.
children
Type: ReactNode
Inherited props
Modifiers
Use these modifiers in the modifiers prop of the SwiftUI version.
Modifiers for any view
accessibilityAddTraitsaccessibilityElementaccessibilityHiddenaccessibilityHintaccessibilityIdentifieraccessibilityInputLabelsaccessibilityLabelaccessibilityRemoveTraitsaccessibilityValueactivityBackgroundTintalignmentGuideallowsTighteninganimationaspectRatiobackgroundbackgroundOverlayblurboldborderbrightnessclippedclipShapecolorInvertcontainerBackgroundcontainerRelativeFrameiOS 17+containerShapecontentShapecontentTransitioniOS 16+contrastcornerRadiuscreateModifierdisableddynamicTypeSizeenvironmentfixedSizefontforegroundColorforegroundStyleframegeometryGroupiOS 17+glassEffectglassEffectIdgrayscalegridCellAnchoriOS 16+gridCellColumnsgridCellUnsizedAxesgridColumnAlignmentiOS 16+hiddenhueRotationidignoreSafeAreaimageScaleinvalidatableContentiOS 17+italickerninglayoutPrioritylineHeightiOS 26+lineLimitlineSpacingluminanceToAlphamaskmatchedGeometryEffectminimumScaleFactormonospacedDigitmultilineTextAlignmentoffsetonAppearonDisappearonGeometryChangeonLongPressGestureonTapGestureopacityoverlaypaddingprivacySensitiveredactedrotation3DEffectrotationEffectsaturationscaleEffectshadowstrikethroughstrokeBordertextCasetinttruncationModeunderlineunredactedwidgetURLzIndex
Sources
The original Expo docs for this page:
- Overlay (SwiftUI) (
source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/overlay.md)