<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/listSectionSpacing(_:)-5t518",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE18listSectionSpacingyQrAA04ListeF0VF"
  },
  "title" : "listSectionSpacing(_:)"
}
-->

# listSectionSpacing(_:)

Sets the spacing between adjacent sections in a `List`.

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

## Parameters

`spacing`

the `ListSectionSpacing` to apply.

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)