Sebastian Faltoni Software Architect. Passionate about Clean Code, Tech, Web, AI, .NET, Python, IOT, Swift, SwiftUI and also Blazor

Hide disclosure arrow indicator on SwiftUI List

35 sec read

If you are looking to remove the arrow which appear on the right of the list row on swiftui, you can use the following trick.


import SwiftUI

struct Item {
    var name : String
}

struct MyCustomView: View{
    var item : Item
    var body: some View {
        Text(item.name)
    }
}

struct DestinationView : View {
    var body: some View {
        Text("Destination")
    }
}

struct ContentView: View {
    var items: [Item] = [
        Item(name: "Pippo"),
        Item(name: "Pluto"),
    ]
    var body: some View {
        NavigationView {
            List{
                ForEach(items, id: \.name) {
                    item in
                    ZStack {
                        MyCustomView(item: item)
                        NavigationLink(destination: DestinationView()) {
                         
                        }.buttonStyle(PlainButtonStyle()).frame(width:0).opacity(0)
                    }
                }
            }
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Basically what is needed for this trick to work is to wrap your list item content inside a ZStack, then you add as first element of the ZStack your view code, then after that you can add the NavigationLink with an empty view which basically does the trick to enable the linking to destination detail view while avoiding to show the disclosure arrow indicator

Sebastian Faltoni Software Architect. Passionate about Clean Code, Tech, Web, AI, .NET, Python, IOT, Swift, SwiftUI and also Blazor

A simple extension to use Combine with PromiseKit and…

Because ServiceStack use PromiseKit for it’s async calls on Swift, i made this little extension that convert a PromiseKit request into a Combine publisher....
Sebastian Faltoni
39 sec read

3 Replies to “Hide disclosure arrow indicator on SwiftUI List”

Leave a Reply

Your email address will not be published. Required fields are marked *