<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/ImmersiveSpace/init(id:for:content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14ImmersiveSpaceV2id3for7contentACyxq_GSS_q_mxAA7BindingVyq_SgGctcfc::OverloadGroup"
  },
  "title" : "init(id:for:content:)"
}
-->

# init(id:for:content:)

Creates the immersive space associated with an identifier for a
specified type of presented data.

```
nonisolated init(id: String, for type: Data.Type, @ImmersiveSpaceContentBuilder content: @escaping (Binding<Data?>) -> Content)
```

## Parameters

`id`

A string that uniquely identifies the immersive space. Ensure
that identifiers are unique among the immersive spaces in your app.

`type`

The type of presented data this immersive space accepts.

`content`

An immersive space content builder that defines the content
for each instance of the immersive space. The closure receives a
binding to the value that you pass to the
[`openImmersiveSpace`](/documentation/SwiftUI/EnvironmentValues/openImmersiveSpace) action when you call that
action to open an immersive space. The system automatically persists
and restores the value of this binding during state restoration.

## Discussion

The space uses the specified content builder to form the content.
Your app invokes this initializer when it presents a value
of the specified `type` using the
[`openImmersiveSpace`](/documentation/SwiftUI/EnvironmentValues/openImmersiveSpace) action.

---

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)