Attachment

public struct Attachment
extension Attachment: View
extension Attachment: _ViewEmptyChecking

Attachment is the UI component used for displaying a single attachment within an AttachmentGroup. It presents attachment details including a thumbnail or preview image, title, subtitle, and footnote.

The component handles various states of attachments:

  • Display of uploaded attachments with thumbnail previews
  • Support for custom content through the default content view builder
  • Interaction events for preview and deletion

Usage

Use the Attachment component to display a file or image attachment with its metadata:

// Display an attachment with a thumbnail generated from a file URL
Attachment(attachmentInfo: myAttachmentInfo) {
  AttachmentThumbnail(url: myAttachmentInfo.primaryURL)
} attachmentTitle: {
  Text(myAttachmentInfo.attachmentName)
} attachmentSubtitle: {
  Text("15MB")
} attachmentFootnote: {
  Text("Oct 20, 2025")
}

// Display an attachment with a custom image
Attachment(attachmentInfo: myAttachmentInfo) {
  Image(systemName: "doc.text")
    .resizable()
    .aspectRatio(contentMode: .fit)
} attachmentTitle: {
  Text(myAttachmentInfo.attachmentName)
} attachmentSubtitle: {
  Text("PDF Document")
} attachmentFootnote: {
  Text("Recently modified")
}

Use with AttachmentGroup to manage collections of attachments:

AttachmentGroup(attachments: $myAttachments) {
  // Custom attachment rendering
  ForEach(myAttachments, id: \.id) { attachment in
    Attachment(attachmentInfo: attachment) {
      AttachmentThumbnail(url: attachment.primaryURL)
    } attachmentTitle: {
      Text(attachment.attachmentName)
    }
  }
}