How it works
WindowResizability describes how a window derives its minimum and maximum size, letting you constrain whether and how far people can resize a scene. You apply it with the windowResizability(_:) scene modifier on a Window, WindowGroup, or Settings scene, choosing whether the window follows the platform's default behavior or takes its size limits from the content it presents. Reach for it when a window's natural size should be governed by its view hierarchy — for example a utility or inspector panel that should never shrink below the size its content needs — rather than by the system's default resizing affordances.
Apply it with the windowResizability(_:) scene modifier
WindowResizability is a value you hand to the windowResizability(_:) modifier on a scene, not a view. The modifier takes one WindowResizability argument and binds the resulting size constraints to that scene's window. In the demo the monospaced caption Text(".windowResizability(_:)") names the exact modifier you'd attach to the enclosing scene that hosts WindowResizabilityDemo.
Defer to the platform with .automatic
The automatic case lets the system decide the window's resizability using its standard rules for the scene type and platform, which is the behavior you get when you never apply the modifier at all. It's the safe default for ordinary document or app windows. The first row labeled ".automatic" with "Platform default" stands in for this case.
Pin the size to content with .contentSize
The contentSize case takes both the minimum and maximum window size from the root view's ideal size, so the window resizes only to fit its content and resists being made larger or smaller. Use it for fixed-layout panels and dialogs. The ".contentSize" row described as "Sized to content" represents this mode.
Set a floor with .contentMinSize
The contentMinSize case derives only the minimum window size from the content while leaving the maximum unconstrained, so people can enlarge the window freely but never shrink it past the point where the content fits. It suits resizable windows that still need a sensible lower bound. The ".contentMinSize" row, "Min from content", maps to this case.
Choose a static member, not an initializer
WindowResizability is a struct you never construct directly; you select one of its type properties — automatic, contentSize, or contentMinSize — and pass it to the modifier. The modes array in the demo lists those same three identifiers by name, mirroring the full set of values you choose from when configuring a scene.
Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct WindowResizabilityDemo: View {
let modes: [(String, String)] = [
("automatic", "Platform default"),
("contentSize", "Sized to content"),
("contentMinSize", "Min from content")
]
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Label("WindowResizability", systemImage: "macwindow")
.font(.headline)
Text(".windowResizability(_:)")
.font(.system(.caption, design: .monospaced))
.foregroundStyle(.secondary)
ForEach(modes, id: \.0) { mode in
HStack {
Image(systemName: "arrow.up.left.and.arrow.down.right")
.foregroundStyle(.blue)
VStack(alignment: .leading) {
Text("." + mode.0).font(.subheadline.bold())
Text(mode.1).font(.caption).foregroundStyle(.secondary)
}
}
}
}
.padding()
}
}