<!--
{
  "availability" : [
    "macOS: 13.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/NSHostingView/sizingOptions",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI13NSHostingViewC13sizingOptionsAA0c6SizingF0Vvp"
  },
  "title" : "sizingOptions"
}
-->

# sizingOptions

The options for how the hosting view creates and updates constraints
based on the size of its SwiftUI content.

```
@MainActor @preconcurrency var sizingOptions: NSHostingSizingOptions { get set }
```

## Discussion

NSHostingView can create minimum, maximum, and ideal (content size)
constraints that are derived from its SwiftUI view content. These
constraints are only created when Auto Layout constraints are otherwise
being used in the containing window.

If the NSHostingView is set as the `contentView` of an `NSWindow`, it
will also update the window’s `contentMinSize` and `contentMaxSize`
based on the minimum and maximum size of its SwiftUI content.

`sizingOptions` defaults to `.standardBounds` (which includes
`minSize`, `intrinsicContentSize`, and `maxSize`), but can be set to an
explicit value to control this behavior. For instance, setting a value
of `.minSize` will only create the constraints necessary to maintain the
minimum size of the SwiftUI content, or setting a value of `[]` will
create no constraints at all.

If a use case can make assumptions about the size of the `NSHostingView`
relative to its displayed content, such as the always being displayed in
a fixed frame, setting this to a value with fewer options can improve
performance as it reduces the amount of layout measurements that need to
be performed. If an `NSHostingView` has a `frame` that is smaller or
larger than that required to display its SwiftUI content, the content
will be centered within that frame.

---

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)