What this thread does
Do first: compare the available width with each ViewThatFits alternative.
Short answer
As of November 2026, use SwiftUI on iOS 16.0+/macOS 13.0+ for ViewThatFits and AnyLayout.
Choose / don't choose
- ViewThatFits: choose for alternatives selected by their ideal content size; don't choose it as state storage for two separately created forms.
- AnyLayout: choose to rearrange the same control subtree without destroying state (Apple).
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
frame(minWidth:idealWidth:maxWidth:) | nil defaults: leave the minimum and ideal width unspecified unless the content needs a constraint | SwiftUI iOS 13+/macOS 10.15+ | source.json) |
frame(maxWidth:) | Omit to adopt the child's sizing behavior, constrained by other non-nil arguments | SwiftUI iOS 13+/macOS 10.15+ | source.json) |
layoutPriority(1) | Essential label above siblings at default 0; it shrinks later, not without limit | SwiftUI iOS 13+/macOS 10.15+ | source.json) |
fixedSize(horizontal:vertical:) | Fixes the ideal size in the specified dimensions; select one or both axes | SwiftUI iOS 13+/macOS 10.15+ | source.json) |
ViewThatFits(in: .horizontal) | Measure width only; preferred variant first, usable compact fallback last; default evaluates both axes | SwiftUI iOS 16+/macOS 13+ | source.json) |
AnyLayout(HStackLayout()) / AnyLayout(VStackLayout()) | Change the layout value while keeping one subtree of controls | SwiftUI iOS 16+/macOS 13+ | source |
Order of operations
2. Put edits, selection and navigation in a stable owner above the layout branch; pass bindings into controls. Use AnyLayout for arrangement changes instead of two stateful copies. Avoid changing .id merely because width changed. 3. For display-only alternatives, supply full → compact choices to ViewThatFits. It falls back to the last child even if none fits (Majid Jabrayilov, July 26, 2022). 4. Resize with long translations and accessibility text sizes while a field is edited; require edits and navigation to survive.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
| Text exceeds parent bounds (symptom) | Horizontal fixedSize keeps ideal width even inside a smaller frame | Use horizontal: false; remove the forced width and allow wrapping or the vertical fallback | source.json) |
| Edits reset on layout switch (symptom) | Conditional HStack/VStack creates different structural identities | Keep model/selection/navigation ownership above alternatives; use one control subtree inside AnyLayout | source |
Missing
- There is no universal numeric minimum, ideal width or breakpoint: these depend on the screen's actual controls and localized content.
- No exact SwiftUI runtime error is promised for clipping; the failures above are visual symptoms.
- The linked source does not confirm: For an icon fallback keep the action's accessibility label (Natalia Panferova, June 11, 2022).
Checked
2026-11-12; Sources read: linked Apple APIs and Majid Jabrayilov’s identity explanation plus the dated layout demonstrations above. No UI commands executed.
Related references: Build Settings; AnyLayout reference.
Not for: SwiftUI NavigationSplitView list/detail navigation; see swiftui-list-detail-navigationsplitview
Started from a post by @Apple, packaged by the editor. Original post