How it works
FormPresentationSizing is a concrete presentation-sizing type that tells SwiftUI to size a presented view the way the system sizes its own form-style sheets, rather than letting the content's intrinsic size or the full screen dictate the bounds. When you present a Form, settings panel, or editing dialog, you usually want a compact, system-consistent footprint that adapts across platforms; reaching for FormPresentationSizing gives you that behavior without hand-tuning frames or detents. You don't construct it directly in most code — you apply it through the .form value passed to the presentationSizing(_:) modifier on the presented content.
Apply it with presentationSizing(.form)
FormPresentationSizing is delivered to a presented view through the presentationSizing(_:) modifier, which accepts any PresentationSizing value. Calling
.presentationSizing(.form)on the sheet's content selects this form-appropriate sizing so the presentation adopts the system's standard form dimensions.Reach it through the .form static accessor
Rather than calling an initializer, you obtain the value from the type-inferred static member
.form, which vends a FormPresentationSizing instance. This is the static-property convention SwiftUI uses for sizing values, so the call site reads as.presentationSizing(.form)with the leading-dot shorthand resolving to FormPresentationSizing.Place it inside a presentation container
FormPresentationSizing only takes effect on content that is actually being presented, so it belongs on the view supplied to a presentation modifier. In the example it is attached to the
Forminside the.sheet(isPresented:)closure, where the sizing governs how that sheet's bounds are computed.Combine with other presentation modifiers
Because presentationSizing(_:) participates in the standard modifier chain, FormPresentationSizing composes with adjacent presentation and layout modifiers applied to the same presented content. Here
.presentationSizing(.form)sits alongside.padding()on theForm, letting the form-style sizing coexist with content insets.
.presentationSizing(.form) to .presentationSizing(.page) and present the same Form to see how the form-style footprint differs from a full-page presentation.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 FormPresentationSizingDemo: View {
@State private var showingForm = true
var body: some View {
Text("Tap to edit settings")
.padding()
.sheet(isPresented: $showingForm) {
Form {
Section("Profile") {
TextField("Name", text: .constant("Ada"))
Toggle("Notifications", isOn: .constant(true))
}
}
.presentationSizing(.form)
.padding()
}
}
}