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.
Apply a style with windowStyle(_:)
WindowStyletakes effect through thewindowStyle(_:)scene modifier, which you attach to a window-presenting scene rather than to a view. In the example this is sketched asWindowGroup { ContentView() }.windowStyle(.hiddenTitleBar): the modifier accepts any value conforming toWindowStyleand tells SwiftUI to frame every window in that group accordingly.Start from the automatic style
The
.automaticstyle is the default conformer, letting SwiftUI pick the window framing that best suits the platform and scene type. Listed in the demo asLabel(".automatic", ...), it's the value you get when you never callwindowStyle(_:)at all, and a safe baseline to override only where you need a specific look.Show or hide the title bar
On macOS,
.titleBarkeeps the conventional bordered title bar while.hiddenTitleBarremoves it so content can extend to the window's edges. The example surfaces both asLabel(".titleBar", ...)andLabel(".hiddenTitleBar", ...); choosing between them is the most common reason to specify aWindowStyleexplicitly.Present a volume with the volumetric style
The
.volumetricstyle, shown asLabel(".volumetric", systemImage: "cube"), is the spatial-computing conformer: it presents the scene as a 3D volume rather than a flat 2D window. It's theWindowStylevalue you pair with volume-aware content on platforms that support depth.
.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.
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()
}
}