listRowInsets

Sets the insets of rows in a list on the specified edges.

View ModifieriOS 26.0+macOS 26.0+tvOS 26.0+watchOS 26.0+visionOS 26.0+

Overloads

2 ways to call compose().listRowInsets(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().listRowInsets(
  edges: SwiftUI.EdgeSet | undefined,
  length: number | null
)
Swift
nonisolated func listRowInsets(
    _ edges: Edge.Set = .all,
    _ length: CGFloat?
) -> some View

Parameters

  • edges*SwiftUI.EdgeSet | undefined

    The edges to set the insets to.

  • length*number | null

    An amount, given in points, to set the insets to on the specified edges.

Return value

A view in which the margins of list sections are set to the specified amount

Discussion

Use this modifier to change the default insets of list rows on the specified edges.

In the example below, the Flavor enumeration provides content for list items. The SwiftUI ForEach structure computes views for each element of the Flavor enumeration and extracts the raw value of each of its elements using the resulting text to create each list row item. The listRowInsets(_:_:) modifier then changes the leading inset of each row of the list and leaves the default insets on the other edges untouched:

struct ContentView: View {
    enum Flavor: String, CaseIterable, Identifiable {
        var id: String { self.rawValue }
        case vanilla, chocolate, strawberry
    }

    var body: some View {
        List {
            ForEach(Flavor.allCases) {
                Text($0.rawValue)
                    .listRowInsets(.leading, 25)
            }
        }
    }
}

When applying multiple listRowInsets modifiers, modifiers with the same edges will override modifiers higher up in the view hierarchy.

See also

More in Lists and tables.