SwiftUI - List - horizontal insets (macOS)

Hi, could you give an advice how to get rid of these horizontal insets(black) between a row and List border ?

        List {
            ForEach(0...5, id : \.self){ Text("\($0)").foregroundColor(.black) }  
              .listRowBackground(Color.white)            
        }
        .listStyle(PlainListStyle())
        .border(Color.yellow)

workaround with padding does not work

.padding(.horizontal, -8) 

and playing with listRowInsets does not work also

.listRowInsets(EdgeInsets())

not sure what's your intent here... if you just remove all color setting calls - "it just works" (in both dark and light modes).

found this which explains it.

thank you, but did not help
clearing the color does not get rid of space between list border and rows border
I guess the behaviour for macOS appeared in XCode 13

indeed. and it's also a googleable (known) problem. perhaps this can work for you as a workaround (put the relevant OS version checks):

    List {
        ForEach(0...5, id : \.self){ Text("\($0)").foregroundColor(.black) }
            .listRowBackground(Color.green)
        }
        .padding(.leading, -8) // ***
        .padding(.trailing, -9) // ***
        .listStyle(PlainListStyle())
    }
Terms of Service

Privacy Policy

Cookie Policy