TechnologiesSwiftUI

VolumetricWindowStyle struct

iOSmacOStvOSwatchOSvisionOS✓ renders

A window style that creates a 3D volumetric window.

How it works

VolumetricWindowStyle presents a window as a bounded three-dimensional volume rather than a flat 2D pane, giving its content real depth in space on visionOS. Reach for it when a scene needs to show 3D models, RealityKit content, or layouts that extend along the z-axis and should be viewable from multiple angles. You don't construct it directly; SwiftUI exposes it through the volumetric static value, which you hand to the windowStyle(_:) modifier on a window scene. It is the volumetric counterpart to the default plain and .automatic window styles, opting a WindowGroup or Window into a volume instead of a plane.

  1. Apply the style with windowStyle(.volumetric)

    VolumetricWindowStyle takes effect through the windowStyle(_:) scene modifier, which sets the presentation for an entire window scene. Passing .volumetric (the static shorthand for the style) turns the scene into a volume, as shown in the demo's .windowStyle(.volumetric) annotation.

  2. Attach it to a window scene, not a view

    The style is a WindowStyle and is only meaningful on a scene such as WindowGroup or Window inside your App body — not on an ordinary view modifier chain. The commented scene WindowGroup { ContentView() } .windowStyle(.volumetric) shows the correct attachment point, with ContentView() (here the VolumetricWindowStyleDemo body) supplying the content placed inside the volume.

  3. Use volume-aware depth in the content

    Because the window now has a z-axis, content destined for a volumetric scene typically uses 3D-aware containers like Model3D or RealityKit views so it reads from any angle. The demo stands in for that depth-bearing content with a flat placeholder — an Image(systemName: "cube.transparent") and a Text("Volumetric Window") label — but in a real volume those would be replaced by geometry that occupies the box.

  4. Compare against the default plain style

    VolumetricWindowStyle sits alongside the automatic and plain window styles; without .volumetric, a WindowGroup renders as a flat plane. Choosing .volumetric is the single switch that distinguishes a volume from a plane, which is why the demo surfaces the literal modifier string .windowStyle(.volumetric) as the thing under study.

Try it — Comment out the .windowStyle(.volumetric) line in the scene annotation (or change it to .windowStyle(.plain)) to see the same content fall back to a flat 2D window with no surrounding volume.

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.

VolumetricWindowStyle.swift
struct VolumetricWindowStyleDemo: View {
    var body: some View {
        VStack(spacing: 12) {
            Image(systemName: "cube.transparent")
                .font(.system(size: 48))
                .foregroundStyle(.tint)
            Text("Volumetric Window")
                .font(.headline)
            Text(".windowStyle(.volumetric)")
                .font(.caption.monospaced())
                .foregroundStyle(.secondary)
        }
        .padding()
        // In an App scene:
        // WindowGroup { ContentView() }
        //     .windowStyle(.volumetric)
    }
}
Live preview
Volumetric Window .windowStyle(.volumetric)
Volumetric Window .windowStyle(.volumetric)
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →