presentationDetents

Sets the available detents for the enclosing sheet.

View ModifieriOS 16.0+macOS 13.0+tvOS 16.0+watchOS 9.0+

Overloads

2 ways to call compose().presentationDetents(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().presentationDetents(
  detents: SwiftUI.PresentationDetent[]
)
Swift
nonisolated func presentationDetents(
    _ detents: Set<PresentationDetent>
) -> some View

Parameters

  • A set of supported detents for the sheet. If you provide more that one detent, people can drag the sheet to resize it.

Discussion

By default, sheets support the PresentationDetent.large detent.

struct ContentView: View {
    @State private var showSettings = false

    var body: some View {
        Button("View Settings") {
            showSettings = true
        }
        .sheet(isPresented: $showSettings) {
            SettingsView()
                .presentationDetents([.medium, .large])
        }
    }
}

See also

More in Presentation.