NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

Removing the top padding of a List

Forums > SwiftUI


I have a view with a TextField, and a List below, like this:

struct ContentView: View {
    var body: some View {
        NavigationStack {

struct ListView: View {
    var body: some View {
    List {

struct MainView: View {
    @State private var searchText = ""

    var body: some View {
        VStack {
            TextField("Search", text: $searchText)

I am trying to move the list closer up to the textfield, but I can't get it to work. I don't want to use a "plain" list, because I'd still like to have the rounded corners and the horizontal padding.

Using padding or offset moves the list, but with the padding of the list itself, so it blocks the textfield. I have tried setting the spacing of the VStack to 0, but it doesn't change anything, and neither does applying any of the following modifiers to the list:

 .onAppear {
 UITableView.appearance() = -35

.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))


.environment(\.defaultMinListHeaderHeight, 0)

Does anyone know how to do this? Thanks


Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until October 1st.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.