How it works
AutomaticPresentationSizing is the presentation-sizing value that hands sizing decisions back to the system. When you present a sheet, SwiftUI normally needs to know how large the presented content should be; this type lets the framework choose that size for you, based on the platform, the presentation context, and the available space. Reach for it as the default starting point for a sheet's dimensions — apply it when you want standard, system-driven behavior rather than committing to a fitted or explicitly proportioned size of your own.
Adopt the PresentationSizing protocol
AutomaticPresentationSizing conforms to the PresentationSizing protocol, the family of values that describe how a presentation determines its size. Because it is a concrete sizing value, it can be passed anywhere a PresentationSizing is expected and slots in alongside siblings like .fitted and .form.
Reach it through the static .automatic value
Rather than constructing the struct directly, you select it through the type's static accessor, written as the leading-dot form
.automatic. This is the conventional, system-determined sizing and serves as the baseline when no other sizing is specified.Apply it with presentationSizing(_:)
You install the sizing on presented content using the
presentationSizing(.automatic)modifier. The call attaches the sizing to the view that the presentation displays, so SwiftUI consults it when laying out the presentation.Place it on the presented content of a sheet
The modifier belongs on the root of the content closure you hand to a presentation such as
.sheet(isPresented:). In the example it sits on theVStackinside the sheet body, which is the surface whose size the system then resolves automatically.
.presentationSizing(.automatic) to .presentationSizing(.fitted) and watch the sheet shrink to hug the VStack's Text content instead of taking the system's default size.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 AutomaticPresentationSizingDemo: View {
@State private var showSheet = true
var body: some View {
Text("Main content")
.padding()
.sheet(isPresented: $showSheet) {
VStack(spacing: 12) {
Text("Automatic Sizing")
.font(.headline)
Text("The system picks the sheet size.")
.foregroundStyle(.secondary)
}
.padding()
.presentationSizing(.automatic)
}
}
}