---
title: "init(id:_:)"
framework: realitykit
role: symbol
role_heading: Initializer
path: "realitykit/attachment/init(id:_:)"
---

# init(id:_:)

Creates an new attachment from an identifier and a closure.

## Declaration

```swift
nonisolated init(id: AnyHashable, @ViewBuilder _ content: @escaping () -> Content)
```

## Parameters

- `id`: An AnyHashable instance that identifies the attachment and a doc://com.apple.RealityKit/documentation/RealityKit/ViewAttachmentEntity.
- `content`: A ViewBuilder instance that contains the views for the attachment.

## Discussion

Discussion You can access details of an attachment entity, such as its bounds, by calling the methods of a ViewAttachmentEntity instance. For example, you can add an attachment that contains the text "hello". Attachment(id: "example") {     Text("hello") } note: The initializer doesn’t automatically add the views to a RealityView instance. You need to explicitly add each entity to your app’s scene hierarchy by directly placing an entity attachment to the view or as a child of another entity that’s already in the view.
