TechnologiesSwiftUIScenes and Windows

WindowStyle protocol

iOSmacOStvOSwatchOSvisionOS✓ renders

A specification for the appearance and interaction of a window.

How it works

WindowStyle is the protocol that describes how a window scene presents its chrome — its title bar, background, and overall framing — independent of the content you place inside. You don't conform to it directly; instead you choose one of SwiftUI's concrete conforming styles and hand it to a scene so the platform draws the window's container appropriately. Reach for it when the default window appearance doesn't fit your app: a media canvas that wants the title bar to recede, a utility window that needs a standard frame, or a spatial scene that should render as a volume.

  1. Apply a style with windowStyle(_:)

    WindowStyle takes effect through the windowStyle(_:) scene modifier, which you attach to a window-presenting scene rather than to a view. In the example this is sketched as WindowGroup { ContentView() }.windowStyle(.hiddenTitleBar): the modifier accepts any value conforming to WindowStyle and tells SwiftUI to frame every window in that group accordingly.

  2. Start from the automatic style

    The .automatic style is the default conformer, letting SwiftUI pick the window framing that best suits the platform and scene type. Listed in the demo as Label(".automatic", ...), it's the value you get when you never call windowStyle(_:) at all, and a safe baseline to override only where you need a specific look.

  3. Show or hide the title bar

    On macOS, .titleBar keeps the conventional bordered title bar while .hiddenTitleBar removes it so content can extend to the window's edges. The example surfaces both as Label(".titleBar", ...) and Label(".hiddenTitleBar", ...); choosing between them is the most common reason to specify a WindowStyle explicitly.

  4. Present a volume with the volumetric style

    The .volumetric style, shown as Label(".volumetric", systemImage: "cube"), is the spatial-computing conformer: it presents the scene as a 3D volume rather than a flat 2D window. It's the WindowStyle value you pair with volume-aware content on platforms that support depth.

Try it — Change the sketched modifier from .windowStyle(.hiddenTitleBar) to .windowStyle(.titleBar) and watch the window regain its standard bordered title bar instead of letting content reach the top edge.

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.

WindowStyle.swift
struct WindowStyleDemo: View {
    // WindowStyle is a Scene protocol applied to a window scene, e.g.:
    //   WindowGroup { ContentView() }
    //       .windowStyle(.hiddenTitleBar)
    // Concrete styles: .automatic, .titleBar, .hiddenTitleBar, .volumetric
    var body: some View {
        VStack(alignment: .leading, spacing: 12) {
            Text("Window Styles")
                .font(.headline)
            Label(".automatic", systemImage: "macwindow")
            Label(".titleBar", systemImage: "macwindow.on.rectangle")
            Label(".hiddenTitleBar", systemImage: "macwindow.badge.plus")
            Label(".volumetric", systemImage: "cube")
        }
        .padding()
    }
}
Live preview
Window Styles .automatic .titleBar .hiddenTitleBar .volumetric
Window Styles .automatic .titleBar .hiddenTitleBar .volumetric
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →