How to remove inset in SwiftUI list rows?

Asked on 06/12/2025

1 search

To remove the inset in SwiftUI list rows, you can use the listRowInsets modifier. This modifier allows you to customize or remove the default insets applied to list rows. Here's an example of how you can use it:

List {
    ForEach(items, id: \.self) { item in
        Text(item)
            .listRowInsets(EdgeInsets()) // Removes the insets
    }
}

In this example, EdgeInsets() is used to remove all insets, making the list rows extend to the full width of the list. You can adjust the EdgeInsets values to customize the insets as needed.

For more detailed information on customizing SwiftUI containers, you might find the session Demystify SwiftUI containers helpful, which covers customization options in SwiftUI.