<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/DocumentCreationSource",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI22DocumentCreationSourceV"
  },
  "title" : "DocumentCreationSource"
}
-->

# DocumentCreationSource

Describes the source used to create a new document.

```
struct DocumentCreationSource
```

## Overview

On iOS, you can declare custom creation sources and use them in
[`NewDocumentButton`](/documentation/SwiftUI/NewDocumentButton).

```
extension DocumentCreationSource {
    static let scanner: Self =
        DocumentCreationSource(id: "document-from-scanner")

    static let template: Self =
        DocumentCreationSource(id: "document-from-template")
}

DocumentGroupLaunchScene("Documents") {
    NewDocumentButton("Scan Document", source: .scanner)
    NewDocumentButton("New from Template", source: .template)
}
```

When a document is created, you can retrieve its source from
[`URLDocumentConfiguration`](/documentation/SwiftUI/URLDocumentConfiguration) or [`FileDocumentConfiguration`](/documentation/SwiftUI/FileDocumentConfiguration):

```
DocumentGroup(newDocument: { MyDocument() }) { configuration in
    if configuration.creationSource == .template {
        TemplateSetupView()
    }
}
```

## Topics

### Creating a source

[`init(id:)`](/documentation/SwiftUI/DocumentCreationSource/init(id:))

Creates a document creation source with the given identifier.

### Identifying a source



---

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)