TechnologiesSwiftUI

PresentedWindowContent struct

iOSmacOStvOSwatchOSvisionOS✓ renders

A view that represents the content of a presented window.

How it works

PresentedWindowContent is the opaque view type SwiftUI produces when a value-presenting scene — such as a WindowGroup(for:) — resolves its content closure for a specific presented value. You rarely name it directly; instead, SwiftUI wraps the view you return from that closure inside a PresentedWindowContent, which carries the decoded presentation value, the window's identity, and its environment down to your view. Reach for it conceptually when you build document- or value-driven windows and want to reason about how a presented value becomes on-screen content.

  1. Return your view from the presentation closure

    A value-presenting scene calls your content closure once per presented value and wraps the result in a PresentedWindowContent. The view you author — here the VStack(spacing: 12) holding the book's Image, title Text, and caption — is exactly the body SwiftUI lifts into that wrapper, so PresentedWindowContentDemo's body defines what each presented window shows.

  2. Bind the view to a presented value

    PresentedWindowContent threads the value that opened the window through to your content. In the example the book string "The Pragmatic Programmer" stands in for that per-window value; in a real WindowGroup(for:) closure it would arrive as the binding SwiftUI decodes, and rendering it via Text(book) is how the wrapper surfaces the presented data.

  3. Inherit the window's environment

    Because PresentedWindowContent sits between the scene and your view, environment values and styling flow through it unchanged. That is why .foregroundStyle(.tint) on the Image and .foregroundStyle(.secondary) on the caption resolve against the presented window's own environment rather than the window that opened it.

  4. Compose modifiers on the wrapped content

    Modifiers you attach apply to the view PresentedWindowContent holds, not to the window chrome. The trailing .padding() and the per-view .font(.largeTitle), .font(.headline), and .font(.caption) all decorate the content SwiftUI presents, leaving window management to the scene.

Try it — Change the book string "The Pragmatic Programmer" to a different title and observe that the presented content updates, illustrating how PresentedWindowContent renders whatever value drives the window.

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.

PresentedWindowContent.swift
struct PresentedWindowContentDemo: View {
    let book = "The Pragmatic Programmer"

    var body: some View {
        VStack(spacing: 12) {
            Image(systemName: "book.closed.fill")
                .font(.largeTitle)
                .foregroundStyle(.tint)
            Text(book)
                .font(.headline)
            Text("Presented in its own window")
                .font(.caption)
                .foregroundStyle(.secondary)
        }
        .padding()
    }
}
Live preview
The Pragmatic Programmer Presented in its own window
The Pragmatic Programmer Presented in its own window
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →