<!--
{
  "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:prepareDocumentURL:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17NewDocumentButtonVA2A4TextVRszrlE_11contentType6source07prepareD3URLACyAEGAA18LocalizedStringKeyV_07UniformH11Identifiers6UTTypeVAA0D14CreationSourceV10Foundation0K0VSgyYaKctcfc::OverloadGroup"
  },
  "title" : "init(_:contentType:source:prepareDocumentURL:)"
}
-->

# init(_:contentType:source:prepareDocumentURL:)

Creates and opens new URL-based documents from a template picker.

```
nonisolated init(_ title: LocalizedStringKey, contentType: UTType, source: DocumentCreationSource, prepareDocumentURL: @escaping () async throws -> URL? = { nil })
```

## Parameters

`title`

A title key for the button.

`contentType`

The content type of the document to create.

`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).

`prepareDocumentURL`

Called when the user taps the button.

---

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)