<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/NewDocumentButton/init(_:contentType:source:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17NewDocumentButtonVA2A4TextVRszrlE_11contentType6sourceACyAEGAESg_07UniformH11Identifiers6UTTypeVSgAA0D14CreationSourceVtcfc::OverloadGroup"
  },
  "title" : "init(_:contentType:source:)"
}
-->

# init(_:contentType:source:)

Creates and opens new documents, tagging them with a creation source.

```
nonisolated init(_ label: Text? = nil, contentType: UTType? = nil, source: DocumentCreationSource)
```

## Parameters

`label`

A label for the button.

`contentType`

An optional content type of the document to create.
If not provided, the first content type of the first document type
listed in the app definition is used.

`source`

A source for the document creation flow. When a document is
created, you can retrieve its source from [`FileDocumentConfiguration`](/documentation/SwiftUI/FileDocumentConfiguration)
or [`URLDocumentConfiguration`](/documentation/SwiftUI/URLDocumentConfiguration).

## Discussion

```
extension DocumentCreationSource {
    static let brainstorming: Self =
        DocumentCreationSource(id: "brainstorming")
}

DocumentGroupLaunchScene("Meeting Minutes") {
    NewDocumentButton(Text("New meeting minutes…"))
    NewDocumentButton(
        Text("New brainstorming meeting…"),
        source: .brainstorming
    )
}
```

---

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)