<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/AttributedTextFormatting/Transferable",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI24AttributedTextFormattingOAAE12TransferableV"
  },
  "title" : "AttributedTextFormatting.Transferable"
}
-->

# AttributedTextFormatting.Transferable

A transferable representation of an attributed string interpreted in a
SwiftUI environment.

```
struct Transferable
```

## Overview

Use this type e.g. with drag and drop APIs or to create a
[`fileExporter(isPresented:item:contentTypes:defaultFilename:onCompletion:onCancellation:)`](/documentation/SwiftUI/View/fileExporter(isPresented:item:contentTypes:defaultFilename:onCompletion:onCancellation:)).

```
struct RichTextEditorView: View {
    @State private var text: AttributedString = ""
    @Environment(\.self) private var environment
    @State var fileExporterIsPresented: Bool = false

    var body: some View {
        TextEditor(text: $text)
            .toolbar {
                Button("Save") {
                    fileExporterIsPresented = true
                }
            }
            .fileExporter(
                isPresented: $fileExporterIsPresented,
                item: AttributedTextFormatting.Transferable(text: text, in: environment)
            ) { result in
                handleResult(result)
            }
            .dropDestination(
                for: AttributedTextFormatting.Transferable.self
            ) { transferables, _ in
                text.replaceSelection(
                    &selection,
                    with: transferables.map {
                        AttributedString(transferable: $0, in: environment)
                    }.joined(separator: AttributedString("\n")))
                return true
            }
    }
}
```

To extract text the text after importing, use attributed string’s
`Foundation/AttributedString/init(transferable:in:)`.

Supported content types include:

- <doc://com.apple.documentation/documentation/UniformTypeIdentifiers/UTType-swift.struct/rtfd>
- <doc://com.apple.documentation/documentation/UniformTypeIdentifiers/UTType-swift.struct/rtf>

## Topics

### Initializers

[`init(text: AttributedString, in: EnvironmentValues)`](/documentation/SwiftUI/AttributedTextFormatting/Transferable/init(text:in:))

Create a transferable representation of an attributed string
as interpreted in a SwiftUI environment.

## Relationships

### Conforms To

[`Transferable`](/documentation/CoreTransferable/Transferable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

---

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)