<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/presentationDetents(_:selection:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE19presentationDetents_9selectionQrShyAA18PresentationDetentVG_AA7BindingVyAGGtF"
  },
  "title" : "presentationDetents(_:selection:)"
}
-->

# presentationDetents(_:selection:)

Sets the available detents for the enclosing sheet, giving you
programmatic control of the currently selected detent.

```
nonisolated func presentationDetents(_ detents: Set<PresentationDetent>, selection: Binding<PresentationDetent>) -> some View
```

## Parameters

`detents`

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

`selection`

A [`Binding`](/documentation/SwiftUI/Binding) to the currently selected detent.
Ensure that the value matches one of the detents that you
provide for the `detents` parameter.

## Discussion

By default, sheets support the [`large`](/documentation/SwiftUI/PresentationDetent/large) detent.

```
struct ContentView: View {
    @State private var showSettings = false
    @State private var settingsDetent = PresentationDetent.medium

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)