<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/sceneAccessory(content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE14sceneAccessory7contentQrqd__yXE_tAA05SceneE7ContentRd__lF"
  },
  "title" : "sceneAccessory(content:)"
}
-->

# sceneAccessory(content:)

Defines any scene accessories associated with `self`.

```
nonisolated func sceneAccessory<C>(@ContentBuilder content: () -> C) -> some View where C : SceneAccessoryContent
```

## Discussion

A scene accessory declares supplementary content that the system
presents on the app’s behalf when an associated piece of system
functionality becomes available, for example when an external display
is connected. The app declares what content to provide;
the system decides when and where to present it. Scene accessories
enhance the app’s experience when available, but the app must remain
fully functional without them.

For example, you can define a scene accessory for previewing a
non-interactive presentation, which may be presented when an external
display is connected:

```
struct RootView: View {
    var document: PresentationDocument

    var body: some View {
        PresentationDocumentView(document: document)
            .sceneAccessory {
                ExternalNonInteractiveAccessory {
                    PresentationPreview(document: document)
                }
            }
    }
}
```

Use the `SceneAccessoryContent/onAvailabilityChange` modifier to
observe a scene accessory’s system-determined availability. Observe the
lifecycle of the accessory’s content using `View/onAppear`,
`View/onDisappear`, and [`scenePhase`](/documentation/SwiftUI/EnvironmentValues/scenePhase).

For example, you can present various controls based on the scene
accessory’s current state:

```
struct RootView: View {
    @State private var isEnabled = false
    @State private var isAvailable = false
    @State private var isPresented = false
    var document: PresentationDocument

    var body: some View {
        PresentationDocumentView(document: document)
            .toolbar {
                if isAvailable {
                    // Include a toolbar button to enable the
                    // scene accessory when a display is available.
                    SecondaryDisplayToggle(isEnabled: $isEnabled)

                    // Include additional toolbar controls once the
                    // accessory is presented.
                    if isPresented {
                        SecondaryDisplayControls()
                    }
                }
            }
            .sceneAccessory {
                ExternalNonInteractiveAccessory(
                    isEnabled: $isEnabled
                ) {
                    PresentationPreview(document: document)
                        .onAppear { isPresented = true }
                        .onDisappear { isPresented = false }
                }
                .onAvailabilityChange { newValue in
                    isAvailable = newValue
                }
            }
    }
}
```

---

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)