<!--
{
  "availability" : [
    "iOS: 18.1.0 -",
    "iPadOS: 18.1.0 -",
    "macCatalyst: 18.1.0 -",
    "macOS: 15.1.0 -",
    "visionOS: 2.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/imagePlaygroundSheet(isPresented:concepts:sourceImage:onCompletion:onCancellation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP15ImagePlaygroundE05imageE5Sheet11isPresented8concepts06sourceD012onCompletion0L12CancellationQrAA7BindingVySbG_SayAD0dE7ConceptVGAA0D0VSgy10Foundation3URLVcyycSgtF"
  },
  "title" : "imagePlaygroundSheet(isPresented:concepts:sourceImage:onCompletion:onCancellation:)"
}
-->

# imagePlaygroundSheet(isPresented:concepts:sourceImage:onCompletion:onCancellation:)

Presents the system sheet to create an image using one or more concepts
and an optional starting image.

```
@MainActor @preconcurrency func imagePlaygroundSheet(isPresented: Binding<Bool>, concepts: [ImagePlaygroundConcept] = [], sourceImage: Image? = nil, onCompletion: @escaping (URL) -> Void, onCancellation: (() -> Void)? = nil) -> some View
```

## Parameters

`isPresented`

A binding to a variable with a Boolean value. Set the Boolean
value to `true` to display the sheet, and set it to `false` to dismiss the sheet.

`concepts`

An array of initial concepts (text descriptions, concepts extracted
from text, drawings) that describe the expected contents of the image.
The person reviewing the image can change these prompts inside the creation UI.

`sourceImage`

An existing image to use as source input for the new image.
The person viewing the sheet can override the image you provide, and choose
different images and concepts inside the creation UI. If you don’t provide
a starting image, the system creates the new image using only the contents
of the `concepts` parameter.

`onCompletion`

The block to receive the generated image. The block
has no return value and receives the following parameter:

- url: A URL with the path to the image. The system saves the file
  at a temporary location inside your app container. Move the file to a new location
  if you intend to keep it after the dismissal of the sheet.
  After executing this block, the system automatically dismisses the sheet.

`onCancellation`

The block to execute when the person exits
the creation UI without choosing an image. After executing this block,
the system automatically dismisses the sheet.

## Discussion

Use this modifier to display the image-creation sheet from one of your SwiftUI
views. The sheet presents a system-provided UI to generate an image from one
or more strings or concepts and an optional image. The sheet gives the person
controls to modify the image before returning it to your app. When the person
dismisses the sheet, the system runs one of the blocks you provided. Use the
completion block to integrate the generated image into your app’s content.

This modifier works only on devices that support the creation of new images.
Check the `ImagePlayground/SwiftUICore/EnvironmentValues/supportsImagePlayground`
environment variable to determine the availability of the feature. The following
code creates a button to display the sheet only when the feature is available:

```swift
@State private var showSheet = false
@State private var createdImageURL: URL? = nil
@Environment(\.supportsImagePlayground) private var supportsImagePlayground
// ....

if supportsImagePlayground {
  Button("Show Generation Sheet") {
    showSheet = true
  }.imagePlaygroundSheet(isPresented: $showSheet) { url in
      createdImageURL = url
  }
}
```

---

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)