<!--
{
  "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(_:)-a2sn",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE18listSectionSpacingyQr14CoreFoundation7CGFloatVF"
  },
  "title" : "listSectionSpacing(_:)"
}
-->

# listSectionSpacing(_:)

Sets the spacing between adjacent sections in a `List` to a custom
value.

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

## Parameters

`spacing`

the amount of spacing to apply.

## Discussion

The following example creates a `List` with 5 pts of spacing between
sections:

```
List {
    Section("Colors") {
        Text("Blue")
        Text("Red")
    }

    Section("Shapes") {
        Text("Square")
        Text("Circle")
    }
}
.listSectionSpacing(5.0)
```

Spacing can also be specified on an individual `Section`, as in this
example:

```
Section("Borders") {
    Text("Dashed")
    Text("Solid")
}
.listSectionSpacing(10.0)
```

If adjacent sections have different spacing applied, each section
applies half its spacing above and below. Sections without
explicit spacing apply the spacing of their adjacent sections.

```
List {
    Section("Colors") {
        Text("Blue")
        Text("Red")
    }

    Section("Borders") {
        Text("Dashed")
        Text("Solid")
    }
    .listSectionSpacing(10.0)

    Section("Shapes") {
        Text("Square")
        Text("Circle")
    }
    .listSectionSpacing(100.0)
}
```

In the above example, the “Colors” and “Borders” section are separated
by 10 pts of spacing, and the “Borders” and “Shapes” section are
separated by 55 pts of spacing.

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)