How it works
ImmersiveSpaceViewContent is the content type that SwiftUI hands you inside an ImmersiveSpace scene on visionOS — it represents the view hierarchy that fills the unbounded space surrounding the person, rather than a flat window. You reach for it whenever you describe what an immersive scene should display, returning a single view from the scene's content closure the same way body returns a view from a View. It is the bridge between the windowed, app-style portion of SwiftUI and the spatial content that opens out into the room. Conceptually it is just SwiftUI content, so everything you already know about composing views applies, but it is the value that gets presented when an ImmersiveSpace is opened.
Return SwiftUI content as the immersive scene's body
ImmersiveSpaceViewContent is produced by the closure of an ImmersiveSpace scene, and that closure is satisfied by any conforming View. In the example, the demo declares a normal View whose
bodyreturns aVStack— the same shape of content you would hand to an ImmersiveSpace, which presents it as the immersive view rather than as a window.Compose the content with ordinary view layout
Because the immersive content is built from standard SwiftUI primitives, you lay it out with familiar containers and modifiers. Here
VStack(spacing: 16)stacks anImage(systemName: "globe"), a titleText("Immersive Space"), and a descriptiveText, exactly as you would inside a window — the difference is the surface they are presented on, not how you author them.Style the content the same way as windowed views
Modifiers that shape appearance carry over unchanged into immersive content. The example applies
.font(.system(size: 56))and.foregroundStyle(.blue)to the globe,.font(.title2.bold())to the heading, and.font(.callout)with.foregroundStyle(.secondary)and.multilineTextAlignment(.center)to the body text, demonstrating that immersive content uses the same styling vocabulary.Let the content be presented when the space opens
The value you return becomes what SwiftUI shows once the ImmersiveSpace is opened via openImmersiveSpace, with
.padding()and the rest of the hierarchy positioned in the space around the viewer. You author the content statically — SwiftUI is responsible for presenting it as the immersive scene's content when the space becomes active.
VStack(spacing: 16) in a RealityView or anchor it to a fixed offset so it sits out in the room, and notice that the same content reads as spatial immersive content rather than a flat panel.Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct ImmersiveSpaceViewContentDemo: View {
var body: some View {
VStack(spacing: 16) {
Image(systemName: "globe")
.font(.system(size: 56))
.foregroundStyle(.blue)
Text("Immersive Space")
.font(.title2.bold())
Text("This view is the content presented inside an ImmersiveSpace on visionOS.")
.font(.callout)
.foregroundStyle(.secondary)
.multilineTextAlignment(.center)
}
.padding()
}
}