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.
Apply the style with windowStyle(.volumetric)
VolumetricWindowStyletakes effect through thewindowStyle(_:)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.Attach it to a window scene, not a view
The style is a
WindowStyleand is only meaningful on a scene such asWindowGrouporWindowinside yourAppbody — not on an ordinary view modifier chain. The commented sceneWindowGroup { ContentView() } .windowStyle(.volumetric)shows the correct attachment point, withContentView()(here theVolumetricWindowStyleDemobody) supplying the content placed inside the volume.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
Model3Dor RealityKit views so it reads from any angle. The demo stands in for that depth-bearing content with a flat placeholder — anImage(systemName: "cube.transparent")and aText("Volumetric Window")label — but in a real volume those would be replaced by geometry that occupies the box.Compare against the default plain style
VolumetricWindowStylesits alongside the automatic and plain window styles; without.volumetric, aWindowGrouprenders as a flat plane. Choosing.volumetricis 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.
.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.
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)
}
}