<!--
{
  "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/DocumentCreationContext",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI23DocumentCreationContextV"
  },
  "title" : "DocumentCreationContext"
}
-->

# DocumentCreationContext

Context about how a document was created.

```
struct DocumentCreationContext
```

## Overview

SwiftUI passes this to the `makeDocument` closure of
[`DocumentGroup`](/documentation/SwiftUI/DocumentGroup). Use [`creationSource`](/documentation/SwiftUI/DocumentCreationContext/creationSource) to determine which
[`NewDocumentButton`](/documentation/SwiftUI/NewDocumentButton) the person tapped and configure the
document accordingly:

```
DocumentGroup { document in
    EditorView(document: document)
} makeDocument: { configuration, context in
    let document = NotesDocument()
    if context.creationSource == .checklist {
        document.template = .checklist
    }
    return document
}
```

## Topics

### Determining whether the document is new

### Accessing creation properties

[`var creationSource: DocumentCreationSource?`](/documentation/SwiftUI/DocumentCreationContext/creationSource)

The source associated with the button that created this document.

## Relationships

### Conforms To

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

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

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

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

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

---

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)