How it works
A WindowLayoutRoot is the proxy that stands in for a window's root content while you arrange that window inside a custom WindowLayout. Rather than holding a view you build yourself, it represents the scene's own root — the content SwiftUI has already produced — so you can place, size, and position it within a layout container of your choosing. Reach for WindowLayoutRoot when a standard window presentation isn't enough and you need to drive where the root content lands, for example when composing utility panels or a bespoke document-window arrangement around the same root view you would otherwise show on its own.
Treat the root view as the laid-out content
WindowLayoutRoot wraps whatever a scene declares as its root — here the VStack containing the macwindow Image, the "Document Window" Text, and its "Root content for a window scene" subtitle. You don't reconstruct that hierarchy inside the layout; the proxy already carries it, and your job is to decide where it sits.
Place the proxy inside a layout container
Because WindowLayoutRoot conforms to View, you embed it in any container — a VStack, an HStack, or a frame — exactly where you want the window's content to appear. The example's own VStack(spacing: 16) is the kind of arrangement the proxy plugs into, letting the surrounding layout drive ordering and spacing.
Stretch the content to fill the window
Apply standard sizing modifiers to the root so it grows to occupy the window's bounds. The example reaches the window edges with .frame(maxWidth: .infinity, maxHeight: .infinity); applied to a WindowLayoutRoot, the same modifier makes the root content expand to fill the area the layout assigns it rather than hugging its intrinsic size.
Inset the root with padding
Layout modifiers compose around the proxy just as they would around any view, so you can give the root breathing room before it meets the window chrome. The .padding() in the example demonstrates that final inset — the root content is positioned, sized, and then padded within the window the layout produces.
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 WindowLayoutRootDemo: View {
var body: some View {
VStack(spacing: 16) {
Image(systemName: "macwindow")
.font(.system(size: 44))
.foregroundStyle(.tint)
Text("Document Window")
.font(.title2.bold())
Text("Root content for a window scene")
.font(.subheadline)
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding()
}
}