SwipeActions for All Views Starting in Xcode 27

  • Jun 12

SwipeActions for All Views Starting in Xcode 27

At WWDC 2026, Apple introduced the next generation of its platforms, including iOS 27, iPadOS 27, macOS 27, watchOS 27, tvOS 27, and visionOS 27, along with significant updates to SwiftUI in Xcode 27.

One of the most welcome additions is the expansion of swipeActions.

Swipe actions have been available since iOS 15 and later across Apple’s platforms (iOS 15+, iPadOS 15+, macOS 12+, Mac Catalyst 15+, watchOS 8+, and visionOS 1+). However, they were previously limited to views displayed inside a List.

Starting with Xcode 27 and the latest OS releases, swipe actions are no longer restricted to List rows. You can now add swipe actions to virtually any SwiftUI view, making it much easier to create interactive experiences throughout your apps.

This enhancement provides significantly more flexibility when building custom layouts using stacks, grids, cards, scroll views, and other SwiftUI containers while still offering the familiar swipe-to-reveal actions users expect.

Let’s see this in action with a practical example.

We’ll start by creating a simple data model that represents some of the latest courses available on DevTechie.com

These are real, live courses, so feel free to visit https://www.devtechie.com and explore them yourself.

struct DTCourses: Identifiable {
    var name: String
    var lessons: Int
    
    var id: String {
        return name + lessons.description
    }
}

extension DTCourses {
    static var sample = [
        DTCourses(name: "Accelerated iOS Development with Claude Code", lessons: 19),
        DTCourses(name: "Agentic iOS App Development with Claude", lessons: 14),
        DTCourses(name: "Ace Your iOS Developer Interview: From Core Concepts to Interview-Ready Expertise", lessons: 11),
        DTCourses(name: "Master In App Purchase in SwiftUI & iOS 26 with SwiftData", lessons: 17),
    ]
}

Next, we will create a simple view to render course details

struct CourseCardView: View {
    let course: DTCourses
    
    var body: some View {
        HStack(spacing: 16) {
            
            VStack(alignment: .leading, spacing: 6) {
                Text(course.name)
                    .font(.headline)
                    .foregroundStyle(.primary)
                    .lineLimit(2)
                
                HStack(spacing: 4) {
                    Image(systemName: "play.circle.fill")
                        .font(.caption)
                        .foregroundStyle(.secondary)
                    Text("\(course.lessons) lessons")
                        .font(.subheadline)
                        .foregroundStyle(.secondary)
                }
            }
        }
        .frame(maxWidth: .infinity, alignment: .leading)
        .padding()
        .glassEffect(.regular.tint(.orange.opacity(0.4)))
    }
}

Let’s use preview to render this view

#Preview {
    CourseCardView(course: DTCourses.sample.first!)
}

We can add swipeActions right here in this view, no need to be inside a collection.

#Preview {
    CourseCardView(course: DTCourses.sample.first!)
        .swipeActions {
            Button(role: .destructive) {
                
            } label: {
                Label("Delete", systemImage: "trash")
            }
        }
}

Applying swipe actions to a single view isn’t particularly useful in a real-world application. Swipe actions become much more valuable when they are attached to a collection of items that users can interact with individually.

To demonstrate this, let’s place our course views inside a scrollable container and render the entire list of courses. This allows each course card to have its own swipe actions, creating an experience similar to what users are familiar with in Mail, Reminders, and other Apple apps.

struct ContentView: View {
    
    @State private var courses: [DTCourses] = DTCourses.sample
    
    var body: some View {
        NavigationStack {
            ScrollView {
                VStack(spacing: 16) {
                    ForEach(courses) { course in
                        CourseCardView(course: course)
                            .swipeActions {
                                Button(role: .destructive) {
                                    courses.removeAll { $0.id == course.id }
                                } label: {
                                    Label("Delete", systemImage: "trash")
                                }
                            }
                    }
                }
                .padding()
            }
            .swipeActionsContainer()
            .navigationTitle("DevTechie Courses")
            .navigationSubtitle("visit DevTechie.com")
        }
    }
}

Notice swipeActionsContainer modifier, when swipe actions were limited to List, SwiftUI automatically handled the coordination between rows. Only one row could remain open at a time, scrolling would close any revealed actions, and tapping elsewhere would dismiss them.

With swipe actions now available on any view, Apple introduced the swipeActionsContainer() modifier to bring the same behavior to custom layouts.

Apply this modifier to a ScrollView or any container that hosts views using the swipeActions(edge:allowsFullSwipe:content:)modifier. The container automatically coordinates swipe interactions by ensuring that:

  • Only one row’s swipe actions are revealed at a time.

  • Scrolling the container dismisses any open swipe actions.

  • Tapping outside the active row closes the currently revealed actions.

List continues to provide this behavior automatically, so no additional configuration is required. However, when building custom row-based interfaces with ScrollView, LazyVStack, LazyHStack, grids, or other container views, you should apply swipeActionsContainer() to achieve the same polished user experience.

With that, we’ve reached the end of this article.

The ability to add swipe actions to any SwiftUI view opens up many new possibilities for building rich, interactive interfaces beyond the traditional List. Combined with swipeActionsContainer(), you can now create custom layouts while maintaining the polished behavior users expect across Apple's platforms.

Thank you for reading. If you found this article helpful and would like to support our work, be sure to visit DevTechie.com, where you’ll find in-depth SwiftUI, iOS, and Apple development courses designed to help you build real-world applications and stay up to date with the latest technologies.

Happy coding, and we will see you in the next article.