WWDC 2025 deal: 30% off our Swift and SwiftUI books! Learn more ...WWDC 2025 deal:30% off our Swift and SwiftUI books >>
Quick Tip Icon
Quick Tip

ControlGroup in context menus in SwiftUI

Starting from iOS 17 and iPadOS 17 we can now use a ControlGroup inside a contextMenu(), enabling more compact access to common actions.

Screenshot of a context menu open showing cut, copy and past all in a horizontal stack.
ContentView()
    .contextMenu {
        ControlGroup {
            Button {
                // cut action
            } label: {
                Label("Cut", systemImage: "scissors")
            }
            
            Button {
                // copy action
            } label: {
                Label("Copy", systemImage: "doc.on.doc")
            }
            
            Button {
                // paste action
            } label: {
                Label("Paste", systemImage: "doc.on.clipboard")
            }
        }
        
        Button(role: .destructive) {
            // delete action
        } label: {
            Label("Delete", systemImage: "trash")
        }
    }

On macOS this code creates a nested sub-menu with cut, copy and paste as items.

SwiftUI Fundamentals by Natalia Panferova book coverSwiftUI Fundamentals by Natalia Panferova book cover

WWDC 2025 offer: 30% off!$35$25

The essential guide to SwiftUI core concepts and APIs

SwiftUI Fundamentalsby Natalia Panferova

  • Explore the key APIs and design patterns that form the foundation of SwiftUI
  • Develop a deep, practical understanding of how SwiftUI works under the hood
  • Learn from a former Apple engineer who worked on widely used SwiftUI APIs
WWDC 2025 offer: 30% off!

The essential guide to SwiftUI core concepts and APIs

SwiftUI Fundamentals by Natalia Panferova book coverSwiftUI Fundamentals by Natalia Panferova book cover

SwiftUI Fundamentals

by Natalia Panferova

$35$25