TechnologiesSwiftUI

DefaultDocumentGroupLaunchActions struct

iOSmacOStvOSwatchOSvisionOS✓ renders

The default actions for the document group launch scene and the document launch view.

How it works

DefaultDocumentGroupLaunchActions is the view SwiftUI draws on a document-based app's launch experience to offer the system-standard launch actions — typically the controls for creating a new document and opening an existing one. When you build a custom launch scene with DocumentGroupLaunchScene, you supply your own background and branding, but you rarely want to reinvent how people start working; this view drops the platform's familiar New and Open affordances into your layout so they look and behave exactly as they do in Apple's own document apps. Reach for it whenever you're customizing a launch screen and want to keep the standard entry points instead of wiring up document creation by hand.

  1. Place the standard launch actions in a custom launch scene

    DefaultDocumentGroupLaunchActions is a View, so you compose it into the overlayActions of a DocumentGroupLaunchScene (or anywhere in your launch layout) the same way the demo arranges its controls inside a VStack(spacing: 16). SwiftUI renders the system-provided New and Open buttons in place — you don't construct the buttons yourself, the way the example hand-builds its Button/Label pair as a stand-in.

  2. Let it provide the New and Open affordances

    The view supplies the two primary launch actions automatically: creating a fresh document and opening an existing one. These map to the roles illustrated by the demo's Label("New Document", systemImage: "plus") and Label("Open", systemImage: "folder"), but with DefaultDocumentGroupLaunchActions the wiring to your DocumentGroup is handled for you rather than left as empty Button {} closures.

  3. Inherit the platform button styling

    DefaultDocumentGroupLaunchActions renders its actions with the system's launch-screen treatment, so the New action reads as the prominent primary and Open as the secondary — the same emphasis the example fakes with .buttonStyle(.borderedProminent) and .buttonStyle(.bordered). You get that hierarchy without choosing button styles yourself, keeping the screen consistent with other document apps.

  4. Compose it alongside your own branding

    Because it's an ordinary view, you can surround DefaultDocumentGroupLaunchActions with your custom title and supporting copy — here the Text("My Documents") heading and the descriptive .font(.footnote) line — and apply layout like .padding() to the whole arrangement. The standard actions slot into your design rather than dictating it.

Try it — Replace the hand-built HStack of Button controls with DefaultDocumentGroupLaunchActions() to swap the placeholder buttons for the real system New and Open actions and see the platform styling and behavior take over.

Example & preview

Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.

DefaultDocumentGroupLaunchActions.swift
struct DefaultDocumentGroupLaunchActionsDemo: View {
    var body: some View {
        VStack(spacing: 16) {
            Text("My Documents")
                .font(.largeTitle.bold())
            Text("DefaultDocumentGroupLaunchActions provides the standard New / Open buttons on a document app's launch screen.")
                .font(.footnote)
                .foregroundStyle(.secondary)
                .multilineTextAlignment(.center)
            HStack(spacing: 12) {
                Button {} label: {
                    Label("New Document", systemImage: "plus")
                }
                .buttonStyle(.borderedProminent)
                Button {} label: {
                    Label("Open", systemImage: "folder")
                }
                .buttonStyle(.bordered)
            }
        }
        .padding()
    }
}
Live preview
My Documents DefaultDocumentGroupLaunchActions provides the standard New / Open buttons on a document app's launch screen. New Document Open
My Documents DefaultDocumentGroupLaunchActions provides the standard New / Open buttons on a document app's launch screen. New Document Open
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →