TechnologiesSwiftUIPresentation and Dialogs

AutomaticPresentationSizing struct

iOSmacOStvOSwatchOSvisionOSiOS 18.0+✓ renders

The default presentation sizing, appropriate for the platform.

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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 the VStack inside the sheet body, which is the surface whose size the system then resolves automatically.

Try it — Change .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.

AutomaticPresentationSizing.swift
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)
            }
    }
}
Live preview
Main content Automatic Sizing The system picks the sheet size.
Main content Automatic Sizing The system picks the sheet size.
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →