<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macOS: 15.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/WindowPlacement",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15WindowPlacementV"
  },
  "title" : "WindowPlacement"
}
-->

# WindowPlacement

A type which represents a preferred size and position for a window.

```
struct WindowPlacement
```

## Overview

When using the `Scene.defaultWindowPlacement(_:)` modifier, you return an
instance of a `WindowPlacement` in the closure you provide.

When constructing a window placement, many initial parameters are optional.
Any value not specified will fall back to the scene’s default behavior and
configuration for sizing and positioning it’s windows.

For example, you can use this to position a window 140 points from the
bottom of the visible area of the screen:

```
Window("Status", id: "status") {
    StatusView()
}
.windowResizability(.contentSize)
.defaultWindowPlacement { content, context in
    let displayBounds = context.defaultDisplay.visibleRect
    let size = content.sizeThatFits(.unspecified)
    let position = CGPoint(
        x: displayBounds.midX - (size.width / 2),
        y: displayBounds.maxY - size.height - 140)
    return WindowPlacement(position: position, size: size)
}
```

## Topics

### Structures

[`struct Position`](/documentation/SwiftUI/WindowPlacement/Position)

A semantic or positional value for the location of a window.

### Initializers

[`init(WindowPlacement.Position?)`](/documentation/SwiftUI/WindowPlacement/init(_:))

Creates a new window placement with an optional position.

[`init(WindowPlacement.Position?, size3D: Size3D?)`](/documentation/SwiftUI/WindowPlacement/init(_:size3D:))

Creates a new window placement with an optional position and 3D size.
Depth is ignored on scenes that don’t support it.

[`init(_:size:)`](/documentation/SwiftUI/WindowPlacement/init(_:size:))

Creates a new window placement with an absolute position and
optional size.

[`init(UnitPoint, width: CGFloat?, height: CGFloat?)`](/documentation/SwiftUI/WindowPlacement/init(_:width:height:))

Creates a new window placement with a display-relative position, with
an optional width and height.

[`init(WindowPlacement.Position?, width: CGFloat?, height: CGFloat?, depth: CGFloat?)`](/documentation/SwiftUI/WindowPlacement/init(_:width:height:depth:))

Creates a new window placement with an optional position and 3D size.
Depth is ignored on scenes or platforms that don’t support it.

[`init(x: CGFloat?, y: CGFloat?, width: CGFloat?, height: CGFloat?)`](/documentation/SwiftUI/WindowPlacement/init(x:y:width:height:))

Creates a new window placement with an optional position and size.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

---

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)