Windows
Display user interface content in a window or a collection of windows.
Overview
The most common way to present a view hierarchy in your app’s interface is with a WindowGroup, which produces a platform-specific behavior and appearance.
[Image]
On platforms that support it, people can open multiple windows from the group simultaneously. Each window relies on the same root view definition, but retains its own view state. On some platforms, you can also supplement your app’s user interface with a single-instance window using the Window scene type.
Configure windows using scene modifiers that you add to the window declaration, like windowStyle(_:) or defaultPosition(_:). You can also indicate how to configure new windows that you present from a view hierarchy by adding the presentedWindowStyle(_:) view modifier to a view in the hierarchy.
For design guidance, see Windows in the Human Interface Guidelines.
Topics
Essentials
Customizing window styles and state-restoration behavior in macOSBringing multiple windows to your SwiftUI app
Creating windows
Styling the associated toolbar
Opening windows
Closing windows
Sizing a window
Positioning and sizing windowsdefaultSize(_:)defaultSize(width:height:)defaultSize(width:height:depth:)defaultSize(_:in:)defaultSize(width:height:depth:in:)windowResizability(_:)WindowResizabilitywindowIdealSize(_:)WindowIdealSize
Positioning a window
defaultPosition(_:)WindowLevelwindowLevel(_:)WindowLayoutRootWindowPlacementdefaultWindowPlacement(_:)windowIdealPlacement(_:)WindowPlacementContextWindowProxyDisplayProxy
Configuring window visibility
WindowVisibilityToggledefaultLaunchBehavior(_:)restorationBehavior(_:)SceneLaunchBehaviorSceneRestorationBehaviorpersistentSystemOverlays(_:)windowToolbarFullScreenVisibility(_:)WindowToolbarFullScreenVisibility
Managing window behavior
WindowManagerRolewindowManagerRole(_:)WindowInteractionBehaviorwindowDismissBehavior(_:)windowFullScreenBehavior(_:)windowMinimizeBehavior(_:)windowResizeBehavior(_:)windowBackgroundDragBehavior(_:)
Interacting with volumes
onVolumeViewpointChange(updateStrategy:initial:_:)supportedVolumeViewpoints(_:)VolumeViewpointUpdateStrategyViewpoint3DSquareAzimuthWorldAlignmentBehaviorvolumeWorldAlignment(_:)WorldScalingBehaviordefaultWorldScaling(_:)WorldScalingCompensationworldTrackingLimitationsWorldTrackingLimitationSurfaceSnappingInfo