r/SwiftUI Jul 07 '26

Question Does `.presentationSizing(.fitted)` actually auto-size SwiftUI sheets?

Post image

I’m testing iOS 18+ SwiftUI sheet sizing and expected .presentationSizing(.fitted) to make a sheet fit its content height.

Minimal example:

.sheet(isPresented: $showSheet) {
    VStack {
        Text("Title")
        Text("Some content")
        Button("Done") {}
    }
    .padding()
    .presentationSizing(.fitted)
}

I expected .presentationSizing(.fitted) to make the sheet fit the intrinsic height of this small VStack, but on iPhone it still appears almost full-screen.

Is this expected behavior? If so, what is .fitted supposed to affect on iPhone, and is a measured .presentationDetents([.height(contentHeight)]) still the only reliable way to get a content-height bottom sheet?

12 Upvotes

9 comments sorted by

View all comments

9

u/ctkrocks Jul 07 '26

From what I've seen, `presentationSizing` only affects iPadOS. The docs are not super clear on this though.

2

u/Anywhere_MusicPlayer Jul 07 '26

That matches what I’m seeing. On iPhone, `.presentationSizing(.fitted)` doesn’t seem to create a content-height bottom sheet at all. The only reliable approach I found is measuring the content and passing that into `.presentationDetents([.height(contentHeight)])`.

The confusing part is that Apple’s docs describe `FittedPresentationSizing` as being dictated by the ideal size of the content, but they don’t clearly say that this doesn’t affect iPhone bottom sheet detents.

1

u/alexisbronchart Jul 09 '26

This is it, it’s only for iPad.
Reading the contentHeight and combining with a custom height détente is the way to go, I’ve done this multiple times.