---
title: "listSectionSpacing(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/listsectionspacing(_:)-5t518"
---

# listSectionSpacing(_:)

Sets the spacing between adjacent sections in a List.

## Declaration

```swift
nonisolated func listSectionSpacing(_ spacing: ListSectionSpacing) -> some View

```

## Parameters

- `spacing`: The doc://com.apple.SwiftUI/documentation/SwiftUI/ListSectionSpacing to apply.

## Discussion

Discussion Pass .default for the default spacing, or use .compact for a compact appearance between sections. The following example creates a List with compact spacing between sections: List {     Section("Colors") {         Text("Blue")         Text("Red")     }

Section("Shapes") {         Text("Square")         Text("Circle")     } } .listSectionSpacing(.compact) Spacing can also be specified on an individual Section, as in this example: Section("Borders") {     Text("Dashed")     Text("Solid") } .listSectionSpacing(.compact) Spacing applied on sections in the List overrides spacing applied on the List as a whole.
