TechnologiesSwiftUI

NavigationControlGroupStyle struct

iOSmacOStvOSwatchOSvisionOS✓ renders

The navigation control group style.

How it works

NavigationControlGroupStyle is the control group style that displays its controls as a navigation-style group, giving a ControlGroup the connected, segmented appearance used for back-and-forward style navigation affordances. Reach for it when you collect related directional or paging controls and want them rendered as a single cohesive unit rather than as separate, free-standing buttons. Like the other built-in ControlGroupStyle values, you don't construct it directly; instead you select it through the style modifier, which lets the system handle the platform-appropriate layout, spacing, and chrome for the grouped controls.

  1. Group the controls in a ControlGroup

    NavigationControlGroupStyle only takes effect on a ControlGroup, which is the container that gathers a set of related controls into one logical unit. In the example the ControlGroup wraps two Button views so they can be treated, laid out, and styled together as a single navigation group rather than as independent buttons.

  2. Apply it with controlGroupStyle(.navigation)

    You opt into the style through the controlGroupStyle(_:) modifier rather than instantiating NavigationControlGroupStyle yourself. Passing the .navigation shorthand resolves to this style and tells SwiftUI to render the enclosed controls with the connected, navigation-oriented presentation; the modifier is attached to the ControlGroup so the style applies to everything inside it.

  3. Let the member controls describe themselves with Label

    The style governs how the group is presented, while each child control supplies its own content. Here the Button views carry Label("Back", systemImage: "chevron.left") and Label("Forward", systemImage: "chevron.right"), so NavigationControlGroupStyle arranges those titled, symbol-bearing controls into the grouped navigation layout without you positioning them by hand.

  4. Rely on the ControlGroupStyle conformance for portability

    NavigationControlGroupStyle conforms to ControlGroupStyle, which is why it slots into controlGroupStyle(_:) interchangeably with the other built-in styles. Because the style is selected by value, you can swap .navigation for a different style on the same ControlGroup and the controls re-render accordingly, with no change to the Button or Label declarations inside.

Try it — Change .controlGroupStyle(.navigation) to .controlGroupStyle(.automatic) and compare how the same ControlGroup of Back and Forward buttons is presented to see what the navigation style contributes.

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.

NavigationControlGroupStyle.swift
struct NavigationControlGroupStyleDemo: View {
    var body: some View {
        ControlGroup {
            Button {
            } label: {
                Label("Back", systemImage: "chevron.left")
            }
            Button {
            } label: {
                Label("Forward", systemImage: "chevron.right")
            }
        }
        .controlGroupStyle(.navigation)
        .padding()
    }
}
Live preview
Back Forward
Back Forward
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →