TechnologiesSwiftUIPresentation and Dialogs

PagePresentationSizing struct

iOSmacOStvOSwatchOSvisionOSiOS 18.0+✓ renders

The size is roughly the size of a page of paper, appropriate for

How it works

PagePresentationSizing is a presentation-sizing type that asks a sheet or other modal presentation to adopt a page-style layout, sizing the presented container the way a full page of content wants to appear rather than hugging its contents. Reach for it when a sheet hosts substantial, page-like material and the default fitted sizing would feel cramped or inconsistent across platforms. You don't construct it directly in everyday code; instead you apply it through the static accessor that vends a value of this type to the presentation, letting SwiftUI resolve the appropriate metrics for the current device and context.

  1. Conform to PresentationSizing to describe a sheet's size

    PagePresentationSizing is one of the concrete types conforming to the PresentationSizing protocol, the family of values that tell a presentation how large to be. It represents the "page" member of that family, sitting alongside the form and fitted sizings, so wherever a PresentationSizing is expected you can supply a page sizing to request page-style dimensions.

  2. Select it with the .page static accessor

    Rather than calling an initializer, you obtain the value through the type's static member, written as .page at the use site. This is the canonical entry point for PagePresentationSizing: it returns a ready-made instance whose metrics SwiftUI computes for you, which is why the example writes .presentationSizing(.page) instead of building a sizing by hand.

  3. Apply it with the presentationSizing(_:) modifier

    A presentation sizing only takes effect when attached to the content of a presentation via the presentationSizing(_:) view modifier. In the example that modifier wraps the sheet's VStack, so the page sizing is what governs the presented container; the modifier passes the PagePresentationSizing value down to the active sheet rather than affecting the view in place.

  4. Place it inside an active presentation

    Because PagePresentationSizing describes how a presentation is sized, it has effect only when there is a presentation to size. Here the .sheet(isPresented:) presentation, driven by showSheet, is that host: .presentationSizing(.page) lives on the sheet's content, so the page sizing applies to the sheet that appears when showSheet is true.

Try it — Change .presentationSizing(.page) to .presentationSizing(.form) and reopen the sheet to see the page sizing's larger, page-style container give way to the more compact form layout.

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.

PagePresentationSizing.swift
struct PagePresentationSizingDemo: View {
    @State private var showSheet = true

    var body: some View {
        Text("Page-sized sheet is open")
            .padding()
            .sheet(isPresented: $showSheet) {
                VStack(spacing: 16) {
                    Text("Page Presentation")
                        .font(.title2.bold())
                    Text("This sheet uses page sizing, fitting the page-style layout.")
                        .multilineTextAlignment(.center)
                }
                .padding()
                .presentationSizing(.page)
            }
    }
}
Live preview
Page-sized sheet is open Page Presentation This sheet uses page sizing, fitting the page-style layout.
Page-sized sheet is open Page Presentation This sheet uses page sizing, fitting the page-style layout.
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →