presentationDragIndicator

Sets the visibility of the drag indicator on top of a sheet.

View ModifieriOS 16.0+macOS 13.0+tvOS 16.0+watchOS 9.0+presentationDragIndicator(_:) in SwiftUI

Declaration

React
compose().presentationDragIndicator(
  visibility: SwiftUI.Visibility
)
Swift
nonisolated func presentationDragIndicator(
    _ visibility: Visibility
) -> some View

Parameters

Discussion

You can show a drag indicator when it isn't apparent that a sheet can resize or when the sheet can't dismiss interactively.

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

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

See also

More in Gestures and input.