<!--
{
  "availability" : [
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Scene/windowIdealPlacement(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI5ScenePAAE20windowIdealPlacementyQrAA06WindowF0VAA0G10LayoutRootV_AA0gF7ContextVtcF"
  },
  "title" : "windowIdealPlacement(_:)"
}
-->

# windowIdealPlacement(_:)

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

```
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.

- content: A proxy for the contents of the window.
- context: An instance of a [`WindowPlacementContext`](/documentation/SwiftUI/WindowPlacementContext) that provides
  contextual information used to size and position windows.

## 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`](/documentation/SwiftUI/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)
        }
    }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)