2

Simple list embedded in navigation view renders as expected:

NavigationView {
        List {
            HStack {
                Text("Row 1")
            }
            HStack {
                Text("Row 2")
            }
            HStack {
                Text("Row 3")
            }
        }
    }

enter image description here

But as soon as I add navigation bar button, I get unexpected paddings around the List.

NavigationView {
        List {
            HStack {
                Text("Row 1")
            }
            HStack {
                Text("Row 2")
            }
            HStack {
                Text("Row 3")
            }
        }
        .navigationBarItems(leading: Button("Add") {}) 
    }

enter image description here

Where are those paddings are coming from and how to get rid of them?

Vlad
  • 245
  • 1
  • 10

1 Answers1

3

That is the default listStyle for that combination. You should explicitly set that to plain:

.listStyle(PlainListStyle())
Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278