<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/sheet(item:onDismiss:content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE5sheet4item9onDismiss7contentQrAA7BindingVyqd__SgG_yycSgqd_0_qd__cts12IdentifiableRd__AaBRd_0_r0_lF"
  },
  "title" : "sheet(item:onDismiss:content:)"
}
-->

# sheet(item:onDismiss:content:)

Presents a sheet using the given item as a data source
for the sheet’s content.

```
nonisolated func sheet<Item, Content>(item: Binding<Item?>, onDismiss: (() -> Void)? = nil, @ContentBuilder content: @escaping (Item) -> Content) -> some View where Item : Identifiable, Content : View
```

## Parameters

`item`

A binding to an optional source of truth for the sheet.
When `item` is non-`nil`, the system passes the item’s content to
the modifier’s closure. You display this content in a sheet that you
create that the system displays to the user. If `item` changes,
the system dismisses the sheet and replaces it with a new one
using the same process.

`onDismiss`

The closure to execute when dismissing the sheet.

`content`

A closure returning the content of the sheet.

## Discussion

Use this method when you need to present a modal view with content
from a custom data source. The example below shows a custom data source
`InventoryItem` that the `content` closure uses to populate the display
the action sheet shows to the user:

```
struct ShowPartDetail: View {
    @State private var sheetDetail: InventoryItem?

    var body: some View {
        Button("Show Part Details") {
            sheetDetail = InventoryItem(
                id: "0123456789",
                partNumber: "Z-1234A",
                quantity: 100,
                name: "Widget")
        }
        .sheet(item: $sheetDetail,
               onDismiss: didDismiss) { detail in
            VStack(alignment: .leading, spacing: 20) {
                Text("Part Number: \(detail.partNumber)")
                Text("Name: \(detail.name)")
                Text("Quantity On-Hand: \(detail.quantity)")
            }
            .onTapGesture {
                sheetDetail = nil
            }
        }
    }

    func didDismiss() {
        // Handle the dismissing action.
    }
}

struct InventoryItem: Identifiable {
    var id: String
    let partNumber: String
    let quantity: Int
    let name: String
}
```

![A view showing a custom structure acting as a data source, providing](images/com.apple.SwiftUI/SwiftUI-View-SheetItemContent@2x.png)

In vertically compact environments, such as iPhone in landscape
orientation, a sheet presentation automatically adapts to appear as a
full-screen cover. Use the [`presentationCompactAdaptation(_:)`](/documentation/SwiftUI/View/presentationCompactAdaptation(_:)) or
[`presentationCompactAdaptation(horizontal:vertical:)`](/documentation/SwiftUI/View/presentationCompactAdaptation(horizontal:vertical:)) modifier to
override this behavior.

### Breakthrough effect

In visionOS, most system presentations appear with a breakthrough effect by
default. To change how the enclosing presentation breaks through
content occluding it, use [`presentationBreakthroughEffect(_:)`](/documentation/SwiftUI/View/presentationBreakthroughEffect(_:)),
like in the following example:

```swift
.sheet(item: $sheetDetail,
       onDismiss: didDismiss) { detail in
    VStack(alignment: .leading, spacing: 20) {
        Text("Part Number: \(detail.partNumber)")
        Text("Name: \(detail.name)")
        Text("Quantity On-Hand: \(detail.quantity)")
    }
    .presentationBreakthroughEffect(.prominent)
    .onTapGesture {
        sheetDetail = nil
    }
}
```

> Passing a `.none` value for a sheet has no effect.

---

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)