listSectionSpacing(_:)
Sets the spacing between adjacent sections in a List.
Declaration
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.