TechnologiesSwiftUIImmersive Spaces and visionOS

FullImmersionStyle struct

iOSmacOStvOSwatchOSvisionOS✓ renders

An immersion style that displays unbounded content that completely replaces

How it works

FullImmersionStyle is a concrete immersion style for visionOS that hides the passthrough view of the wearer's physical surroundings and presents your content as the only thing they see. It conforms to the ImmersionStyle protocol, so you don't construct it directly with a custom initializer; instead you select it through the static accessor full and hand it to an immersive space. Reach for it when an experience should take over the wearer's environment completely — a virtual world, a planetarium, a fully rendered scene — rather than blending content into the real room the way mixed or progressive immersion does.

  1. Refer to the style through the .full accessor

    FullImmersionStyle is surfaced as a static member on ImmersionStyle, so you spell it as the leading-dot shorthand .full rather than calling an initializer. Because the property's type is the existential any ImmersionStyle, the same style value can hold any style, while .full pins it to full immersion: @State private var style: any ImmersionStyle = .full.

  2. Apply it with immersionStyle(selection:in:)

    The .immersionStyle(selection:in:) modifier is where the style takes effect. The selection argument is a binding to your current style and the in argument lists the styles the scene is allowed to use; passing .full for both — .immersionStyle(selection: $style, in: .full) — declares that this content runs fully immersed.

  3. Bind selection so the system can drive the style

    Because selection takes a Binding, you pass $style rather than the plain value. This lets the runtime read and write the active style, so the immersion can change in response to the experience while the bound style state stays the source of truth for FullImmersionStyle being active.

  4. List the permitted styles in the in: parameter

    The in: parameter enumerates every style the space may switch among; listing only .full constrains the experience to full immersion alone. To offer choices you would widen this list (for example to also include .mixed or .progressive), and the binding in selection would then move between them.

Try it — Change the in: argument from .full to .mixed in .immersionStyle(selection: $style, in: .full) and watch the surroundings reappear through passthrough instead of being fully replaced.

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.

FullImmersionStyle.swift
struct FullImmersionStyleDemo: View {
    @State private var style: any ImmersionStyle = .full

    var body: some View {
        VStack(spacing: 16) {
            Image(systemName: "visionpro")
                .font(.system(size: 44))
            Text("Full Immersion")
                .font(.headline)
            Text("Replaces your surroundings entirely.")
                .font(.caption)
                .foregroundStyle(.secondary)
        }
        .padding()
        .immersionStyle(selection: $style, in: .full)
    }
}
Live preview
Full Immersion Replaces your surroundings entirely.
Full Immersion Replaces your surroundings entirely.
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →