TechnologiesSwiftUI

AutomaticControlGroupStyle struct

iOSmacOStvOSwatchOSvisionOS✓ renders

The default control group style.

How it works

AutomaticControlGroupStyle is the default style applied to a ControlGroup, the type SwiftUI uses whenever you don't explicitly choose another control group style. Rather than fixing a single appearance, it lets the system pick the presentation that's most appropriate for the context in which the control group appears — a horizontal row of controls in a toolbar, a menu when space is constrained, and so on. Reach for it when you want a group of related controls to look and behave like a native, platform-appropriate cluster without dictating the layout yourself, and you get it for free simply by placing controls in a ControlGroup.

  1. Group related controls in a ControlGroup

    A ControlGroup collects several controls that act on a common subject so SwiftUI can present them as one cohesive unit. Here the group's content closure holds three related actions — the Button("Cut", systemImage: "scissors"), Button("Copy", ...), and Button("Paste", ...) controls — which AutomaticControlGroupStyle will arrange together.

  2. Apply the style with .controlGroupStyle(.automatic)

    The controlGroupStyle(_:) modifier sets the style for a control group and the groups within it. Passing .automatic selects AutomaticControlGroupStyle, the system-chosen default; writing it explicitly here documents that you're deferring the presentation decision to SwiftUI rather than overriding it.

  3. Let context drive the presentation

    Because AutomaticControlGroupStyle resolves to a context-appropriate appearance, the same ControlGroup adapts to where it lives — inline in this view's body, but rendered differently if it were placed in a toolbar or menu. You write the controls once and the style adapts the layout for you.

  4. Use .automatic as the baseline to swap from

    Since .automatic is the implicit default, its main role in code is as an explicit baseline you can replace. Changing the argument of controlGroupStyle(.automatic) to another style is all it takes to move from the system's choice to a specific presentation, while the Button content stays untouched.

Try it — Change .controlGroupStyle(.automatic) to .controlGroupStyle(.navigation) and watch the same Cut/Copy/Paste buttons re-arrange into a different presentation, revealing what the automatic style was choosing for you.

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.

AutomaticControlGroupStyle.swift
struct AutomaticControlGroupStyleDemo: View {
    var body: some View {
        ControlGroup {
            Button("Cut", systemImage: "scissors") {}
            Button("Copy", systemImage: "doc.on.doc") {}
            Button("Paste", systemImage: "doc.on.clipboard") {}
        }
        .controlGroupStyle(.automatic)
        .padding()
    }
}
Live preview
Cut Copy Paste
Cut Copy Paste
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →