---
title: "windowIdealPlacement(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/scene/windowidealplacement(_:)"
---

# windowIdealPlacement(_:)

Provides a function which determines a placement to use when windows of a scene zoom.

## Declaration

```swift
nonisolated func windowIdealPlacement(_ makePlacement: @escaping (WindowLayoutRoot, WindowPlacementContext) -> WindowPlacement) -> some Scene

```

## Parameters

- `makePlacement`: A closure which returns the ideal placement for a window derived from this scene.

## Discussion

Discussion The default behavior will size the window to its maximum size, or the bounds of the display, whichever is smaller. By overriding this behavior, you can provide a size that is appropriate for the contents of your window. This modifier’s closure takes two parameters. content provides a proxy for the root content of the window. context is an instance of a WindowPlacementContext that provides contextual information used to size and position windows. For example, you can provide a placement with a height equal to the display bounds, and a width based on your content’s ideal width: struct MyApp: App {     var body: some Scene {         WindowGroup {             ContentView()         }         .windowIdealPlacement { content, context in             let displayBounds = context.defaultDisplay.visibleRect             let proposal = ProposedViewSize(                 width: nil, height: displayBounds.height)             let contentSize = content.sizeThatFits(proposal)             return .init(                 width: contentSize.width,                 height: contentSize.height)         }     } }

## See Also

### Positioning a window

- [defaultPosition(_:)](swiftui/scene/defaultposition(_:).md)
- [WindowLevel](swiftui/windowlevel.md)
- [windowLevel(_:)](swiftui/scene/windowlevel(_:).md)
- [WindowLayoutRoot](swiftui/windowlayoutroot.md)
- [WindowPlacement](swiftui/windowplacement.md)
- [defaultWindowPlacement(_:)](swiftui/scene/defaultwindowplacement(_:).md)
- [WindowPlacementContext](swiftui/windowplacementcontext.md)
- [WindowProxy](swiftui/windowproxy.md)
- [DisplayProxy](swiftui/displayproxy.md)
